Quell
July 20th, 2006, 01:12 PM
Hello.
I have the following code, but it crashes with and access violation error:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <commctrl.h>
#include <SHELLAPI.H>
#include <tchar.h>
#include <Dbghelp.h>
#include <cstring>
#pragma comment(lib,"Dbghelp.lib")
OPENFILENAME ofn;
void GetFileName()
{
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = NULL;
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFile = _T("\0dllfilehere");
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = _T("Open\0");
ofn.nFilterIndex = 0;
ofn.lpstrDefExt = NULL;
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrFilter = _T("*.dll\0\0");
GetOpenFileName(&ofn);
return;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
GetFileName();
return 0;
}
Any ideas why?
I have the following code, but it crashes with and access violation error:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <commctrl.h>
#include <SHELLAPI.H>
#include <tchar.h>
#include <Dbghelp.h>
#include <cstring>
#pragma comment(lib,"Dbghelp.lib")
OPENFILENAME ofn;
void GetFileName()
{
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = NULL;
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFile = _T("\0dllfilehere");
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = _T("Open\0");
ofn.nFilterIndex = 0;
ofn.lpstrDefExt = NULL;
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrFilter = _T("*.dll\0\0");
GetOpenFileName(&ofn);
return;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
GetFileName();
return 0;
}
Any ideas why?