Visual Studio .NET doesnt like this code. How do I fix it?
The following code gives me errors when Using Visual Studio .NET
Any ideas?
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//the main entry point of the program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
//show simple message box with text "Hello World!"
MessageBox(NULL, "Hello World", "Message Box Works", NULL);
return (0);
}
Thanks in advance,
toejam2000
I might also suggest checking out C#. Raw Win32 code is just not worth it anymore. You can cut down those 200 lines of code to about 20 using WinForms and C#. But then again, to each his own.
As kitofr said, it's likely that you;ve created a C++ console project instead of a Windows executable.
When you create a console project, the linker looks for a int main(int argc, char *argv[]) function for the program's entry point. When you use a windows project, it looks for the WinMain function you have defined here.
If this is the problem, you should be recieving a linker error that mentions something about symbol main (or _main) not being found. To fix this, either twiddle with your project settings or recreate the project as a Windows executable.
When you create a console project, the linker looks for a int main(int argc, char *argv[]) function for the program's entry point. When you use a windows project, it looks for the WinMain function you have defined here.
If this is the problem, you should be recieving a linker error that mentions something about symbol main (or _main) not being found. To fix this, either twiddle with your project settings or recreate the project as a Windows executable.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement