WNDCLASS的lpszClassName成员赋值
给WNDCLASS的lpszClassName成员赋值,在vs2008下报错
error C2440: '=' : cannot convert from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
网上的程序都是直接用 "example"这种方式赋值.
我看了一下LPCWSTR 是 wchar_t * 类型的,
定义wchar_t型数组赋值成 "example"也报错.
究竟该怎样赋值?
WNDCLASS lpszClassName
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra = 0;
wndcls.cbWndExtra = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor = LoadCursor(NULL, IDC_HAND);
wndcls.hIcon = LoadIcon(NULL, IDI_QUESTION);
wndcls.lpfnWndProc = WindowProc;
wndcls.lpszClassName = "clsname"; //怎样给类名赋值?
wndcls.lpszMenuName = NULL;
wndcls.style = CS_VREDRAW | CS_HREDRAW;
RegisterClass(&wndcls);
}
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
return 0;
}