Thread: (VC6 -> VC++ 2005 Express)WinMain overload error

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    74

    Exclamation (VC6 -> VC++ 2005 Express)WinMain overload error

    Hello everyone. I have a specific problem relating to Microsoft Visual C++ 2005 Express Edition.

    I wrote some code in Visual C++ 6.0 and it runs perfectly fine, but I recently downloaded Microsoft Visual C++ 2005 Express + Windows Platform SDK 2003 R2. I have set it up correctly following the setup guidelines at http://msdn.microsoft.com/vstudio/ex...k/default.aspx

    Yet, when I create a new Empty Win32 App in 2005 Express and just use my code that I wrote in VC6 I get errors for which I do not know how to fix. Here they are:

    error C2731: 'WinMain' : function cannot be overloaded
    see declaration of 'WinMain'
    Code:
    int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPTSTR cmdLine, int cmdShow);
    error C2440: '=' : cannot convert from 'const char [16]' to 'LPCWSTR'
    Code:
    windowClassEx.lpszClassName = "Card Games Main";
    error C2664: 'LoadBitmapW' : cannot convert parameter 2 from 'const char [11]' to 'LPCWSTR'
    Code:
    cardsBmp = LoadBitmap(instance, "deck_cards");
    So whats the deal, eh? Has the entry WinMain function changed? Am I writing it improperly?

    Also, why does it complain about my strings? I've tried casting them to (LPCWSTR), but that didn't work. Any ideas to my problems?

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Try LPSTR in your WinMain declaration instead of LPTSTR.

    The other errors are caused by unicode being enabled by default in VC++ 2005. Use the TEXT macro:
    Code:
    windowClassEx.lpszClassName = TEXT("Card Games Main");
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    74
    Thank you very much JaWiB!! After reading your post I did a google on UNICODE & VC++ 2005 and came up with this URL: http://forums.microsoft.com/msdn/sho...15916&siteid=1

    That explained how to disable UNICODE character set and now everything is working great.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM