#include <9pm/windows.h>
#include <9pm/u.h>
#include <9pm/libc.h>

ATOM WINAPI
RegisterClass(CONST WNDCLASSW *lpWndClass)
{
	ATOM a;
	WNDCLASSA wc;

	if(win_useunicode)
		return RegisterClassW(lpWndClass);

	memcpy(&wc, lpWndClass, sizeof(wc));
	if(wc.lpszMenuName)
		wc.lpszMenuName = win_wstr2utf(lpWndClass->lpszMenuName);
	if((int)wc.lpszClassName >= (1<<16))
		wc.lpszClassName = win_wstr2utf(lpWndClass->lpszClassName);

	a = RegisterClassA(&wc);
	win_free(wc.lpszMenuName);
	if((int)wc.lpszClassName >= (1<<16))
		win_free(wc.lpszClassName);
	return a;
}
