Sign in to follow this  
Wasif Hyder

Help With Win32 Program

Recommended Posts

Wasif Hyder    122
#define WIN32_LEAN_AND_MEAN
#include "stdafx.h"
#include <windows.h> 
#include <windowsx.h>

int WINAPI WinMain    ( HINSTANCE   hInstance,
		        HINSTANCE   hPrevInstance,
                        LPSTR       lpCmdLine,
                        int         nCmdShow )
{

           MessageBox ( NULL, 
			"Title",
                        "Hello", 
			MB_OK | MB_ICONEXCLAMATION );
					           
return(0);

}
I'm having issues with this code. Here's the error according to the compiler error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [6]' to 'LPCWSTR' The error is on this line
 MB_OK | MB_ICONEXCLAMATION ); 

Share this post


Link to post
Share on other sites
jpetrie    13138
The problem was that the compiler was set to use Unicode strings (thus the call to MessageBoxW) but the parameters were regular string literals, not wide ones.

The solution was either to use wide literals (L"string") or set the compiler to use Multibyte strings. One or the other.

Share this post


Link to post
Share on other sites

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