Home > Software engineering >  RegisterClassEx () function returns 0 is what is going wrong
RegisterClassEx () function returns 0 is what is going wrong

Time:04-07

Modifed WNDCLASSEX wcex;
The HWND HWND;
MSG MSG.
TCHAR szWindowClass []=L "Example";
TCHAR szTitle []=L "My Windows";

Wcex. CbSize=sizeof (modifed WNDCLASSEX);
Wcex. Style=0;
Wcex. LpfnWndProc=WndProc;
Wcex. CbClsExtra=0;
Wcex. CbWndExtra=0;
Wcex. HInstance=hInstance;
Wcex. HIcon=LoadIcon (hInstance, MAKEINTRESOURCE (IDI_APPLICATION));
Wcex. HCursor=LoadCursor (NULL, IDC_ARROW);
Wcex. LpszMenuName=NULL;
Wcex. LpszClassName=szWindowClass;
Wcex. HIconSm=LoadIcon (wcex hInstance, MAKEINTRESOURCE (IDI_APPLICATION));

if (! RegisterClassEx (& amp; Wcex)) {
MessageBox (NULL, _T (" window class registration failed!" ), _T (" window to register "), NULL);
return 1;
}

Code are made according to the book, the comparison again found no errors, displays the running of the VS2019 and DevC++ window class registered failure, RegisterClassEx function return value is zero, could you tell me where is the problem

CodePudding user response:

GetLastError () to see the error code is?



CodePudding user response:

reference 1st floor zgl7903 response:
GetLastError () to see the error code is?



some strange problems,,, in order to facilitate the GetLastError, I put the last if changed to the following appearance
if (! RegisterClassEx (& amp; Wcex)) {
ATL: : cstrings s;
S. ormat (_T (" % d "), GetLastError ());
MessageBox (NULL, s, _T (registered "window"), NULL);
return 1;
}

Then the probability of this program has to run,,, also have the error probability and the error code is 87, if it is the appearance of the original is still not run all the time

CodePudding user response:

87 ERROR_INVALID_PARAMETER
The parameter is incorrect.

Set a breakpoint, single step, to see if there are any more resources under no load success?


  • Related