wchar* question
Sam Hu
samhudotsamhu at gmail.com
Thu Sep 3 02:37:16 PDT 2009
Given below code(Win32 SDK):
int /*LRESULT*/ wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_LBUTTONDOWN:
{
wchar* szFileName=cast(wchar*)(new wchar[1024]);// ***questioned line
HINSTANCE hInstance=GetModuleHandleW(null);
GetModuleFileNameW(hInstance,szFileName,1024);
MessageBoxW(null,cast(const wchar*)szFileName, "Full Path:",
MB_ICONINFORMATION);
}
break;
}
My program runs OK and can print the exe path as expected.But if I change
wchar* szFileName=cast(wchar*)(new wchar[1024]);
to
wchar* szFileName;
The program runs also but prints blank.Why?
Thanks for your help in advance.
Regards,
Sam
More information about the Digitalmars-d-learn
mailing list