I'm having troubles with GetOpenFileName on NT4.0 in the sense that no dialog box is displayed.
I searched in the forum but didn't file such a problem.
I'm trying to use the MSDN example which I copied as it is (C code but I guess I would have the same problem using asm).

GetOpenFileName returns 0, then I call CommDlgExtendedError and it returns 2 that is CDERR_INITIALIZATION.
Below is the code.

OPENFILENAME ofn;? ? ? ?// common dialog box structure
char szFile[260];? ? ? ?// buffer for file name

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;

// Display the Open dialog box.

if (GetOpenFileName(&ofn)==TRUE)
? ?MessageBox (hWnd,ofn.lpstrFile,"Selected File", MB_OK) ;
? ?dwRes = CommDlgExtendedError () ; // CDERR_INITIALIZATION

Any hint is well appreciated, thanx. :shock:

Posted on 2005-07-01 08:13:07 by _OuzO_
Buffer pointed by lpstrFile must begin with NULL character.

Pointer to a buffer that contains a file name used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary.
Posted on 2005-07-01 08:43:05 by arafel
Great!!!!? :D It works!!!!

Thank you!
Posted on 2005-07-01 10:15:03 by _OuzO_