Sign in to follow this  

Visual Studio .NET doesnt like this code. How do I fix it?

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this