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

ATOM WINAPI
RegisterClassEx(CONST WNDCLASSEXW *lpWndClass)
{
	ATOM a;
	WNDCLASSEXA wc;

	if(win_useunicode)
		return RegisterClassExW(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 = RegisterClassExA(&wc);
	win_free(wc.lpszMenuName);
	if((int)wc.lpszClassName >= (1<<16))
		win_free(wc.lpszClassName);
	return a;
}
