Sign in to follow this  
MadsGustaf

problem in Win32 API in visual c++

Recommended Posts

MadsGustaf    144
For some reason my code does not work in VC++ :S it works fine in Dev-C++. but in VC++ it gives me these errors:
Quote:
Error 1 error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' c:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\hello worldww\hello worldww\s.cpp 39 Error 2 error C2664: 'MessageBox' : cannot convert parameter 2 from 'const char [37]' to 'LPCTSTR' c:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\hello worldww\hello worldww\s.cpp 43 Error 3 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' c:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\hello worldww\hello worldww\s.cpp 58 Error 4 error C2664: 'MessageBox' : cannot convert parameter 2 from 'const char [27]' to 'LPCTSTR' c:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\hello worldww\hello worldww\s.cpp 60

Share this post


Link to post
Share on other sites
programwizard    100
Try turning off Unicode. Go to the Project menu, then Project Properties. Under Configuration Properties, select General, and make sure the box next to Character Set says Use Multi-Byte Character Set.

Share this post


Link to post
Share on other sites
_goat    804
Those are quite definitely wide-character to narrow-character errors. Either turn off Unicode (which is probably better to support), or put the correct macro around any string literal.

Share this post


Link to post
Share on other sites
Crypter    748
Right click your project, go to "Project Properties"

Select "Configuation Properties->General" in the left tree plain

Insure "Character Set" is "Not Set" (ie, not UNICODE)

If you whish for wide strings, set it to "Multibyte character set" as programwizard said.

Share this post


Link to post
Share on other sites
MadsGustaf    144
thanks! that solved it. unfuntualy it gives me a "new" problem. in VC++ the compiler complains about this code:

LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
//Denne procedure bliver kaldt hver gang der er en besked til vores vindue, eller dens vinduer, kig længere nede for forklaring
{
switch(Msg){
case WM_CLOSE: //Øver, vi er nødt til at lukke
DestroyWindow(hwnd); //Destruer vores vindue
break;
case WM_DESTROY: //Lad os poste den sidste besked
PostQuitMessage(0);
break;
default: // Ikke noget vi gider at rode med, send den videre til default message handleren
DefWindowProc(hwnd, Msg, wParam, lParam);
break;

}
}



and gives me this error:

Quote:

Error 1 error C4716: 'WndProc' : must return a value c:\documents and settings\mads\dokumenter\visual studio 2005\projects\hello worldww\hello worldww\s.cpp 20


the funny thing is, this error dosent show in Dev-C++, were it compiles and runs without a problem.

edit: shouldnt [ code] & [ /code] organize my code on the forum?

Share this post


Link to post
Share on other sites
xargon123    138
Well, as the error says you need a return value. Do this:

LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
//Denne procedure bliver kaldt hver gang der er en besked til vores vindue, eller dens vinduer, kig længere nede for forklaring
{
switch(Msg){
case WM_CLOSE: //Øver, vi er nødt til at lukke
DestroyWindow(hwnd); //Destruer vores vindue
return TRUE;
case WM_DESTROY: //Lad os poste den sidste besked
PostQuitMessage(0);
return TRUE;
default: // Ikke noget vi gider at rode med, send den videre til default message handleren
DefWindowProc(hwnd, Msg, wParam, lParam);
return FALSE;

}

return FALSE;
}

cheers,
xarg

Share this post


Link to post
Share on other sites
MadsGustaf    144
that gives me a ton of new errors. Heres the full code:

#include <windows.h>


const char KlasseNavn[] = "WIN32 API"; //Klasse navnet

LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) //Denne procedure bliver kaldt hver gang der er en besked til vores vindue, eller dens vinduer, kig længere nede for forklaring
{
switch(Msg){
case WM_CLOSE: //Øver, vi er nødt til at lukke
DestroyWindow(hwnd); //Destruer vores vindue
break;
case WM_DESTROY: //Lad os poste den sidste besked
PostQuitMessage(0);
break;
default: // Ikke noget vi gider at rode med, send den videre til default message handleren
DefWindowProc(hwnd, Msg, wParam, lParam);
break;

}

}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg; //En message variabel
WNDCLASSEX wc; //Vores vindue klasse
HWND hwnd; // Handleren til vinduet


wc.cbSize = sizeof(WNDCLASSEX); //Størrelsen på WNDCLASSEX i bytes
wc.style = 0; //Ingen ekstra styles
wc.lpfnWndProc = WndProc; //Vindue proceduren, den tager sig af alle beskeder
wc.cbClsExtra = 0; //Skal vi ikke bruge
wc.cbWndExtra = 0; //Skal vi ikke bruge
wc.hInstance = hInstance; //hIstance, kommer fra hInstance, variablen i WinMain.
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); //Load et ikon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); //Load en cursor
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); //Vælg farve til vinduet
wc.lpszMenuName = NULL; //Ingen menu
wc.lpszClassName = KlasseNavn; //Vores klassenavn
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Load et lille ikon

if(!RegisterClassEx(&wc)){ //Forsøger at registrere vores vindue klasse, ellers spytter vi en box i hovedet på brugeren, og stopper programmet
MessageBox(NULL, "Kunne ikke registrere vindue klassen", "Fejl", MB_OK | MB_ICONEXCLAMATION);
return 0; //Stopper programmet
}
//Så skal vi lave selve vinduet
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, //Laver en kant på vinduet
KlasseNavn, //Angiver vores klasse navn
"Hej verden, nu fra et vindue", //Titlen på vores vindue
WS_OVERLAPPEDWINDOW, //Angiver at det er et normalt vindue vi vil lave (dette er en sammentrækning af en masse styles)
CW_USEDEFAULT, //Vælg en standard x poisition til vinduet
CW_USEDEFAULT, //Vælg en standard y poisition til vinduet
300, //Bredden på vinduet
200, //Højden på vinduet
NULL, //Vi har ingen ejer af vinduet
NULL, //Ingen menu
hInstance, //Handleren til .exe filen
NULL); //Skal vi ikke bruge
if(hwnd == NULL){ //Vinduet kunne ikke oprettes, smid en fejl i hovedet på brugeren og luk ned
MessageBox(NULL, "Kunne ikke oprette vinduet", "Fejl", MB_OK | MB_ICONEXCLAMATION);
return 0; //Stopper programmet
}

//Hvis vi er nået så langt, har vi en vindue, og en vindue klasse, nu mangler vi bare at vise vores vindue, og sørge for at fange alle messages der bliver sendt til det.

ShowWindow(hwnd, nCmdShow); //Viser vores vindue, paramenteren nCmdShow, er måden det skal vises på, og vi viser det, ligesom det er blevet ønsket.
UpdateWindow(hwnd); //Opdaterer vores vindue

//Dette er lidt tricky, dette loop sørger for at vores vindue, modtager alle messages, der bliver sendt til den, d.v.s. at vi får atvide, når f.eks. at vores vindue bliver oprette. Når det resizes osv.
while(GetMessage(&Msg, hwnd, 0, 0) > 0){ //Der er en besked fortsæt
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

return Msg.wParam; //Retunerer Msgs wParam
}

i dont know the macro to enclose my code in a codeblock, sorry.

Share this post


Link to post
Share on other sites
TheUnbeliever    963
[source lang="cpp"]Your code here[/source] tags.

What are the new errors? I'll try to compile it myself, to see what I get, but it's still worth posting at least the topmost error.

EDIT: Okay, I've got it working in VC++ Express Edition (you hadn't added the return values to WndProc). Only changes made were:

LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) //Denne procedure bliver kaldt hver gang der er en besked til vores vindue, eller dens vinduer, kig længere nede for forklaring
{
switch(Msg)
{
case WM_CLOSE: //Øver, vi er nødt til at lukke
DestroyWindow(hwnd); //Destruer vores vindue
return 1;
break;
case WM_DESTROY: //Lad os poste den sidste besked
PostQuitMessage(0);
return 1;
break;
default: // Ikke noget vi gider at rode med, send den videre til default message handleren
return DefWindowProc(hwnd, Msg, wParam, lParam);
break;
}
}





Now, I swear that the rest of this thing shouldn't compile. It looks like there are mismatched curly brackets everywhere - and yet the IDE seems to think they line up. EDIT: Actually, removing all the comments helped me see it better (I think the Danish and lack of indentation to start with was doing for my eyes ;-) ) - it's fine, with the above changes.

EDIT: Fixed demo tags
EDIT: Fixed demo tags, again

Share this post


Link to post
Share on other sites
MadsGustaf    144
*code from TheUnbeliever*
#include <windows.h>


const char KlasseNavn[] = "WIN32 API"; //Klasse navnet

LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) //Denne procedure bliver kaldt hver gang der er en besked til vores vindue, eller dens vinduer, kig længere nede for forklaring
{
switch(Msg)
{
case WM_CLOSE: //Øver, vi er nødt til at lukke
DestroyWindow(hwnd); //Destruer vores vindue
return 1;
break;
case WM_DESTROY: //Lad os poste den sidste besked
PostQuitMessage(0);
return 1;
break;
default: // Ikke noget vi gider at rode med, send den videre til default message handleren
return DefWindowProc(hwnd, Msg, wParam, lParam);
break;
}
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg; //En message variabel
WNDCLASSEX wc; //Vores vindue klasse
HWND hwnd; // Handleren til vinduet


wc.cbSize = sizeof(WNDCLASSEX); //Størrelsen på WNDCLASSEX i bytes
wc.style = 0; //Ingen ekstra styles
wc.lpfnWndProc = WndProc; //Vindue proceduren, den tager sig af alle beskeder
wc.cbClsExtra = 0; //Skal vi ikke bruge
wc.cbWndExtra = 0; //Skal vi ikke bruge
wc.hInstance = hInstance; //hIstance, kommer fra hInstance, variablen i WinMain.
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); //Load et ikon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); //Load en cursor
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); //Vælg farve til vinduet
wc.lpszMenuName = NULL; //Ingen menu
wc.lpszClassName = KlasseNavn; //Vores klassenavn
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Load et lille ikon

if(!RegisterClassEx(&wc)){ //Forsøger at registrere vores vindue klasse, ellers spytter vi en box i hovedet på brugeren, og stopper programmet
MessageBox(NULL, "Kunne ikke registrere vindue klassen", "Fejl", MB_OK | MB_ICONEXCLAMATION);
return 0; //Stopper programmet
}
//Så skal vi lave selve vinduet
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, //Laver en kant på vinduet
KlasseNavn, //Angiver vores klasse navn
"Hej verden, nu fra et vindue", //Titlen på vores vindue
WS_OVERLAPPEDWINDOW, //Angiver at det er et normalt vindue vi vil lave (dette er en sammentrækning af en masse styles)
CW_USEDEFAULT, //Vælg en standard x poisition til vinduet
CW_USEDEFAULT, //Vælg en standard y poisition til vinduet
300, //Bredden på vinduet
200, //Højden på vinduet
NULL, //Vi har ingen ejer af vinduet
NULL, //Ingen menu
hInstance, //Handleren til .exe filen
NULL); //Skal vi ikke bruge
if(hwnd == NULL){ //Vinduet kunne ikke oprettes, smid en fejl i hovedet på brugeren og luk ned
MessageBox(NULL, "Kunne ikke oprette vinduet", "Fejl", MB_OK | MB_ICONEXCLAMATION);
return 0; //Stopper programmet
}

//Hvis vi er nået så langt, har vi en vindue, og en vindue klasse, nu mangler vi bare at vise vores vindue, og sørge for at fange alle messages der bliver sendt til det.

ShowWindow(hwnd, nCmdShow); //Viser vores vindue, paramenteren nCmdShow, er måden det skal vises på, og vi viser det, ligesom det er blevet ønsket.
UpdateWindow(hwnd); //Opdaterer vores vindue

//Dette er lidt tricky, dette loop sørger for at vores vindue, modtager alle messages, der bliver sendt til den, d.v.s. at vi får atvide, når f.eks. at vores vindue bliver oprette. Når det resizes osv.
while(GetMessage(&Msg, hwnd, 0, 0) > 0){ //Der er en besked fortsæt
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

return Msg.wParam; //Retunerer Msgs wParam
}


Quote:
Error 1 error LNK2028: unresolved token (0A000011) "extern "C" int __stdcall DestroyWindow(struct HWND__ *)" (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 2 error LNK2028: unresolved token (0A000012) "extern "C" int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function "extern "C" int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z) s.obj
Error 3 error LNK2028: unresolved token (0A000017) "extern "C" unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)" (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 4 error LNK2028: unresolved token (0A000018) "extern "C" void __stdcall PostQuitMessage(int)" (?PostQuitMessage@@$$J14YGXH@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 5 error LNK2028: unresolved token (0A00001E) "extern "C" struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)" (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 6 error LNK2028: unresolved token (0A000025) "extern "C" int __stdcall TranslateMessage(struct tagMSG const *)" (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 7 error LNK2028: unresolved token (0A000029) "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z) s.obj
Error 8 error LNK2028: unresolved token (0A00002C) "extern "C" struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)" (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 9 error LNK2028: unresolved token (0A00002D) "extern "C" long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)" (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 10 error LNK2028: unresolved token (0A000031) "extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 11 error LNK2028: unresolved token (0A000035) "extern "C" long __stdcall DispatchMessageA(struct tagMSG const *)" (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function "extern "C" long __cdecl DispatchMessage(struct tagMSG const *)" (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z) s.obj
Error 12 error LNK2028: unresolved token (0A000038) "extern "C" int __stdcall UpdateWindow(struct HWND__ *)" (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 13 error LNK2028: unresolved token (0A000039) "extern "C" struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)" (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 14 error LNK2019: unresolved external symbol "extern "C" int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function "extern "C" int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z) s.obj
Error 15 error LNK2019: unresolved external symbol "extern "C" long __stdcall DispatchMessageA(struct tagMSG const *)" (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function "extern "C" long __cdecl DispatchMessage(struct tagMSG const *)" (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z) s.obj
Error 16 error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z) s.obj
Error 17 error LNK2019: unresolved external symbol "extern "C" long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)" (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 18 error LNK2019: unresolved external symbol "extern "C" void __stdcall PostQuitMessage(int)" (?PostQuitMessage@@$$J14YGXH@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 19 error LNK2019: unresolved external symbol "extern "C" int __stdcall DestroyWindow(struct HWND__ *)" (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z) s.obj
Error 20 error LNK2019: unresolved external symbol "extern "C" int __stdcall TranslateMessage(struct tagMSG const *)" (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 21 error LNK2019: unresolved external symbol "extern "C" int __stdcall UpdateWindow(struct HWND__ *)" (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 22 error LNK2019: unresolved external symbol "extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 23 error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)" (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 24 error LNK2019: unresolved external symbol "extern "C" unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)" (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 25 error LNK2019: unresolved external symbol "extern "C" struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)" (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 26 error LNK2019: unresolved external symbol "extern "C" struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)" (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z) s.obj
Error 27 fatal error LNK1120: 26 unresolved externals C:\Documents and Settings\mads\Dokumenter\Visual Studio 2005\Projects\hello worldww\Debug\hello worldww.exe

Share this post


Link to post
Share on other sites
TheUnbeliever    963
They're linker errors, not compiler errors. It looks like you haven't got user32.lib listed as a linker dependency.

Open your project in Visual Studio
Right click your project
Click Properties
Click the little + next to 'Configuration Properties' if it's there
Click the little + next to 'Linker'
Click 'Input'
Click 'Additional Dependencies'
Click the button at the right that says '...'
Make sure that there's a tick in the checkbox that says 'Inherit from parent or project defaults'
Now check that the list of 'Inherited Values' is something like:
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib

If not, do a search on your computer for them and then copy and paste their filepaths into the textbox at the top of the 'Additional Dependencies' window.

Share this post


Link to post
Share on other sites
MadsGustaf    144
WOW! thanks! i had added those files you talk about +odbc32.lib and odbccp32.lib, when i first got VC++.
Seems like it was that "Inherit from parent or project defaults" box i hadnt checked,.

Thanks TheUnbeliever <3! :bow:

edit: is there anyway to choose having a 'check' on "Inherit from parent or project defaults" as standard on all my VC++ files? or would this cause problems in future applications?

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