Advertisement Jump to content


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


Registering a window class

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

If you intended to correct an error in the post then please contact us.

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.hCursor = LoadCursor(NULL, IDC_ARROW);
	main_window_struct.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	main_window_struct.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
	main_window_struct.hInstance = this_time;
	main_window_struct.lpfnWndProc = &message_router;
	main_window_struct.lpszClassName = "Cloneness";
	main_window_struct.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU); = NULL;

	DWORD blah = GetLastError();
Any and all help is appreciated!

Share this post

Link to post
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]; some initialisation section do...

strcpy(class_name, "Cloneness");

...and then...

main_window_struct.lpszClassName = class_name;

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!