-
Open File
Can Anyone tell me whats wrong with this code because it just crashes the program.
TCHAR sFilePath[MAX_PATH] = {NULL};
TCHAR sFileName[STRING_LENGTH];
DWORD dwFilePathSize;
TCHAR sFilter[STRING_LENGTH] = {"Bitmap \0 *.bmp \0 \0"};
OPENFILENAME OpenFile;
LPITEMIDLIST pSelectedFolder;
DWORD dwFileExtension;
DWORD dwFileOffset;
OpenFile.lStructSize = sizeof(OPENFILENAME);
OpenFile.lpstrFilter = sFilter;
OpenFile.hwndOwner = NULL;
OpenFile.nFilterIndex = 0;
OpenFile.lpstrFileTitle = sFileName;
OpenFile.nMaxFileTitle = sizeof(sFileName) - 1;
OpenFile.lpstrInitialDir = NULL;
OpenFile.lpstrFile = sFilePath;
OpenFile.nMaxFile = MAX_PATH;
OpenFile.nFileOffset = strlen(sFilePath);
GetOpenFileName(&OpenFile);
-
TCHAR sFilter[STRING_LENGTH] = "Bitmap\0*.bmp\0";
would be correct. May be the error, may not, I don't know.
In any case you should first ZeroMemory the complete struct:
ZeroMemory(&OpenFile, sizeof(OpenFile));