#### Archived

This topic is now archived and is closed to further replies.

# Registering a window class

This topic is 5035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''ve had several programs now where I open a window, whatever. It''s basic. All of a sudden, I find myself unable to do that. A little debugging/testing, and I find that the window class isn''t being registered. So, I hunt down the error code. According to MSDN, the code means "The system cannot find the file specified." Which leaves me totally confused. My use of files had nothng to do with my registration, and there error doesn''t exist before I try to register the class. Anyways, I think I''ve rambeled enough. Here''s the pertinent code:
//prepare window

this_time = hInstance;
WNDCLASSEX main_window_struct;
main_window_struct.cbClsExtra = 0;
main_window_struct.cbSize = sizeof(WNDCLASSEX);
main_window_struct.cbWndExtra = 0;
main_window_struct.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
main_window_struct.hInstance = this_time;
main_window_struct.lpfnWndProc = &message_router;
main_window_struct.lpszClassName = "Cloneness";
main_window_struct.style = NULL;
RegisterClassEx(&main_window_struct);

DWORD blah = GetLastError();

Any and all help is appreciated!

##### Share on other sites
The problem is the way you have declared the class name.

Try declaring a global char array as follows:

char class_name[MAX_PATH];

...in some initialisation section do...

strcpy(class_name, "Cloneness");

...and then...

main_window_struct.lpszClassName = class_name;