RegisterClass fails with Error Code 2

896 Views Asked by At

I am creating a splash for a program that I'm making but RegisterClass keeps on failing (2: The system cannot find the file specified.)

My code is this:

WNDCLASS wc = {0};
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = g_hinstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
if (wc.hCursor == NULL)
{
#ifdef DEBUG
    log_debug("ShowSplash:CreateSplashWindow: LoadCursor failed: %d", GetLastError());
#endif
    return NULL;
}
wc.lpszClassName = classname;
if (RegisterClass(&wc) == 0);
{
#ifdef DEBUG
    log_debug("ShowSplash:CreateSplashWindow: RegisterClass failed: %d", GetLastError());
#endif
    return NULL;
}

g_hinstance is the HINSTANCE DllMain gets
classname is the name of the window class

1

There are 1 best solutions below

1
casablanca On BEST ANSWER

There's a stray semicolon at the end of this line:

if (RegisterClass(&wc) == 0);

The error code is actually from some previous call, but the block always gets executed because of the extra semicolon.