-
GetOpenFileName
Hello,
I have a program that use GetOpenFileName API to play a song. It works well until the user try to open a second song, the program bug. I run my program in debugger mode and figure out that it bug when he gets to GetOpenFileName.
Here's my code:
PHP Code:
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = "Text Files (*.wav)\0*.wav\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
GetOpenFileName(&ofn);
Does someone knows why it bugs?
-
I see some typos, but I don't see any failure that would cause it to crash the second time it runs... Maybe if you submit the whole thing...
-
dim pOpenfilename as OPENFILENAME
const MAX_BUFFER_LENGTH=256
WITH pOpenfilename
.hwndOwner=hwnd
.hInstance=App.hInstance
.lpstrFile=String(MAX_BUFFER_LENGTH,0)
.nMaxFile=MAX_BUFFER_LENGTH-1
.nMaxFileTitle=MAX_BUFFER_LENGTH-1
.lstructSize=len(pOpenfilename)
end with
I think it will work