From 52ab4949b40f8749230530873eede2daf9a624e6 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 21 Jan 2017 10:31:09 +1100 Subject: [PATCH] [Project64] Preserve current dir when calling GetOpenFileName --- Source/Common/path.cpp | 37 +++++++ Source/Common/path.h | 3 + .../Debugger/Debugger-MemoryDump.cpp | 25 +---- Source/Project64/UserInterface/GuiClass.cpp | 70 +++--------- .../Project64/UserInterface/MainMenuClass.cpp | 104 +++++------------- .../Project64/UserInterface/MainMenuClass.h | 2 +- .../Settings/SettingsPage-AdvancedOptions.cpp | 20 +--- .../Project64/UserInterface/SupportWindow.cpp | 2 +- Source/Project64/main.cpp | 17 +-- 9 files changed, 99 insertions(+), 181 deletions(-) diff --git a/Source/Common/path.cpp b/Source/Common/path.cpp index d0d686a2b..c86ec16bf 100644 --- a/Source/Common/path.cpp +++ b/Source/Common/path.cpp @@ -5,6 +5,10 @@ #ifdef _WIN32 #include #include +#pragma warning(push) +#pragma warning(disable : 4996) // warning C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared +#include +#pragma warning(pop) #else #include #include @@ -999,6 +1003,39 @@ bool CPath::Exists() const #endif } +#ifdef _WIN32 +bool CPath::SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist) +{ + CPath CurrentDir(CURRENT_DIRECTORY); + + OPENFILENAME openfilename; + char FileName[MAX_PATH]; + memset(&FileName, 0, sizeof(FileName)); + memset(&openfilename, 0, sizeof(openfilename)); + + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hwndOwner; + openfilename.lpstrFilter = FileFilter; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = InitialDir; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_HIDEREADONLY | (FileMustExist ? OFN_FILEMUSTEXIST : 0); + + bool res = GetOpenFileName(&openfilename); + if (CPath(CURRENT_DIRECTORY) != CurrentDir) + { + CurrentDir.ChangeDirectory(); + } + if (!res) + { + return false; + } + m_strPath = FileName; + cleanPathString(m_strPath); + return true; +} +#endif + //------------------------------------------------------------- // Post : Return TRUE on success // Task : Delete file diff --git a/Source/Common/path.h b/Source/Common/path.h index 45c0006ff..2c03aa6dc 100644 --- a/Source/Common/path.h +++ b/Source/Common/path.h @@ -135,6 +135,9 @@ public: //File Information bool IsFile() const { return !IsDirectory(); } bool Exists() const; +#ifdef _WIN32 + bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist); +#endif //Directory operations bool DirectoryCreate(bool bCreateIntermediates = true); diff --git a/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp b/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp index 7f594d24c..95d1835a7 100644 --- a/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp @@ -52,29 +52,16 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, break; case IDC_BTN_CHOOSE_FILE: { - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - OPENFILENAME openfilename; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - strcpy(Directory, CPath(CPath::MODULE_DIRECTORY)); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = m_hWnd; - openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); - if (GetOpenFileName(&openfilename)) + + CPath FileName; + if (FileName.SelectFile(m_hWnd, CPath(CPath::MODULE_DIRECTORY), "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0", false)) { - char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(FileName, drive, dir, fname, ext); - if (strlen(ext) == 0) + if (FileName.GetExtension().length() == 0) { - strcat(FileName, ".txt"); + FileName.SetExtension("txt"); + SetDlgItemText(IDC_FILENAME, FileName); } - SetDlgItemText(IDC_FILENAME, FileName); } g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); } diff --git a/Source/Project64/UserInterface/GuiClass.cpp b/Source/Project64/UserInterface/GuiClass.cpp index 13da62698..0e7f74458 100644 --- a/Source/Project64/UserInterface/GuiClass.cpp +++ b/Source/Project64/UserInterface/GuiClass.cpp @@ -984,58 +984,33 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath); if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImageIPL(IPLROM.c_str()))) { - // Open DDROM - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + CPath FileName; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { g_BaseSystem->RunFileImageIPL(FileName); // Open Disk - openfilename.lpstrFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; - if (GetOpenFileName(&openfilename)) + const char * N64DDFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), N64DDFilter, true)) { if (g_BaseSystem->RunDiskImage(FileName)) + { g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); + } } } } else { // Open Disk - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + CPath FileName; + const char * Filter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { if (g_BaseSystem->RunDiskImage(FileName)) + { g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); + } } } } @@ -1157,23 +1132,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath); if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str()))) { - // Open DDROM - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) - { + CPath FileName; + const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + { CN64System::RunFileImage(FileName); } } diff --git a/Source/Project64/UserInterface/MainMenuClass.cpp b/Source/Project64/UserInterface/MainMenuClass.cpp index 896b0936d..b86c6fae0 100644 --- a/Source/Project64/UserInterface/MainMenuClass.cpp +++ b/Source/Project64/UserInterface/MainMenuClass.cpp @@ -90,29 +90,15 @@ int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg) return TranslateAccelerator((HWND)hWnd, (HACCEL)m_AccelTable, (LPMSG)lpMsg); } -stdstr CMainMenu::ChooseFileToOpen(HWND hParent) +std::string CMainMenu::ChooseFileToOpen(HWND hParent) { - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hParent; - openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + CPath FileName; + const char * Filter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { - return stdstr(FileName); + return FileName; } - return stdstr(""); + return ""; } void CMainMenu::SetTraceModuleSetttings(SettingID Type) @@ -123,7 +109,7 @@ void CMainMenu::SetTraceModuleSetttings(SettingID Type) void CMainMenu::OnOpenRom(HWND hWnd) { - stdstr File = ChooseFileToOpen(hWnd); + std::string File = ChooseFileToOpen(hWnd); if (File.length() == 0) { return; @@ -144,22 +130,9 @@ void CMainMenu::OnOpenRom(HWND hWnd) stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath); if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str()))) { - // Open DDROM - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + CPath FileName; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { g_BaseSystem->RunFileImage(FileName); } @@ -238,30 +211,21 @@ void CMainMenu::OnSaveAs(HWND hWnd) void CMainMenu::OnLodState(HWND hWnd) { - char Directory[255], SaveFile[255]; - OPENFILENAME openfilename; - - memset(&SaveFile, 0, sizeof(SaveFile)); - memset(&openfilename, 0, sizeof(openfilename)); + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); + char Directory[255]; UISettingsLoadStringVal(Directory_LastSave, Directory, sizeof(Directory)); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; - openfilename.lpstrFile = SaveFile; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; - - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); - if (GetOpenFileName(&openfilename)) + CPath SaveFile; + const char * Filter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; + if (SaveFile.SelectFile(hWnd, Directory, Filter, false)) { g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); - char SaveDir[MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(SaveFile, drive, dir, fname, ext); - _makepath(SaveDir, drive, dir, NULL, NULL); - UISettingsSaveString(Directory_LastSave, SaveDir); + if (!SaveFile.DirectoryExists()) + { + SaveFile.DirectoryCreate(); + } + UISettingsSaveString(Directory_LastSave, SaveFile.GetDriveDirectory()); g_BaseSystem->ExternalEvent(SysEvent_LoadMachineState); } g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_LoadGame); @@ -331,27 +295,15 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI break; case ID_SYSTEM_SWAPDISK: WriteTrace(TraceUserInterface, TraceDebug, "ID_SYSTEM_SWAPDISK"); - // Open Disk - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) { - g_Disk->SaveDiskImage(); - g_Disk->SwapDiskImage(FileName); + // Open Disk + CPath FileName; + const char * Filter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + { + g_Disk->SaveDiskImage(); + g_Disk->SwapDiskImage(FileName); + } } break; case ID_SYSTEM_SAVE: diff --git a/Source/Project64/UserInterface/MainMenuClass.h b/Source/Project64/UserInterface/MainMenuClass.h index 420d8df20..4161402ff 100644 --- a/Source/Project64/UserInterface/MainMenuClass.h +++ b/Source/Project64/UserInterface/MainMenuClass.h @@ -86,7 +86,7 @@ private: std::wstring GetSaveSlotString(int Slot); stdstr GetFileLastMod(const CPath & FileName); void RebuildAccelerators(void); - stdstr ChooseFileToOpen(HWND hParent); + std::string ChooseFileToOpen(HWND hParent); void SetTraceModuleSetttings(SettingID Type); static void SettingsChanged(CMainMenu * _this); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp index 0032daf92..d6bc8d30d 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp @@ -112,24 +112,12 @@ void CAdvancedOptionsPage::UpdatePageSettings(void) m_InUpdateSettings = false; } -void CAdvancedOptionsPage::SelectFile(LanguageStringID Title, CModifiedEditBox & EditBox) +void CAdvancedOptionsPage::SelectFile(LanguageStringID /*Title*/, CModifiedEditBox & EditBox) { - // Open DDROM - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); + const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str()); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = m_hWnd; - openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + CPath FileName; + if (FileName.SelectFile(m_hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { EditBox.SetChanged(true); EditBox.SetWindowText(FileName); diff --git a/Source/Project64/UserInterface/SupportWindow.cpp b/Source/Project64/UserInterface/SupportWindow.cpp index 779004a9a..fe5b226a4 100644 --- a/Source/Project64/UserInterface/SupportWindow.cpp +++ b/Source/Project64/UserInterface/SupportWindow.cpp @@ -90,7 +90,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* SetWindowLong(GWL_STYLE, dwStyle); ::EnableWindow(GetDlgItem(IDCANCEL), false); - srand (time(NULL)); + srand ((uint32_t)time(NULL)); SetTimer(0, ((rand() % 35) + 5) * 1000, NULL); } return TRUE; diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index e79341419..5883b37e5 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -40,21 +40,10 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath); if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str()))) { - // Open DDROM - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - openfilename.lStructSize = sizeof(openfilename); - //openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) + CPath FileName; + const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(NULL, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { CN64System::RunFileImage(FileName); }