-
December 17th, 2010, 11:51 AM
#1
[RESOLVED] Portability
Hello Friends, I have the next problem.
When I programm this simple application to generate a Window, I get an executable file. If I run the executable file on other computer, I get an error message "Can not find the component", "Didn't find the MSVCR100d.dll". Why can't I run the application on other computers? Thanks!!
Code:
#include "stdafx.h"
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
// Create the window.
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
// Run the message loop.
MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
EndPaint(hwnd, &ps);
}
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
-
December 17th, 2010, 11:59 AM
#2
Re: Portability
It doesn't run because the computer where you run it does not have the required VC++ DLLs (in this case the C/C++ runtime, but it can also be MFC or ATL, depending on your app type). See this FAQ with links to redistributables to install on that machine: http://www.codeguru.com/forum/showthread.php?t=494136.
However, notice that you are trying to run a Debug build. That won't work with the redistrituables from the above FAQ. You need to build and deploy a Release configuration.
-
December 17th, 2010, 12:30 PM
#3
Re: Portability
Well, I have installed redistributable packages for VC++ Studio 2010. But it still don't work. I am working with Visual Studio C++ 2010 Express, and i don't know how to do it, and how to build and deploy a Release configuration.... Can you help me please?? Thanks!!
-
December 18th, 2010, 03:35 AM
#4
Re: Portability
At the top in Visual Studio there is a dropdown box where you can select Debug and Release.
Set that to Release and to a rebuild.
It's against the EULA to distribute a Debug build of your applications.
-
December 18th, 2010, 05:47 AM
#5
Re: Portability
Ok now it's works!!! sorry I am a beginner programming in Visual C++. Thank you very much!
-
December 19th, 2010, 07:17 AM
#6
Re: [RESOLVED] Portability
How I said, I'm new programming in visual studio. I have programming in C/C++ and Java in Linux, but I would like programming in Windows, Process and Drivers and so on. I am following the guide of msdn, http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx. Do you recommend me another guide?? Thanks you very much
-
December 20th, 2010, 05:04 AM
#7
Re: [RESOLVED] Portability
Originally Posted by suizVisual
No. Maybe some books about Windows programming.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|