Check if project64 is running, if so terminate it
This commit is contained in:
parent
33342a77c5
commit
a144327aa0
|
@ -47,6 +47,7 @@ enum SettingID {
|
|||
Setting_AutoSleep,
|
||||
Setting_AutoStart,
|
||||
Setting_AutoFullscreen,
|
||||
Setting_CheckEmuRunning,
|
||||
Setting_EraseGameDefaults,
|
||||
|
||||
Setting_AutoZipInstantSave,
|
||||
|
|
|
@ -107,6 +107,7 @@ void CSettings::AddHowToHandleSetting ()
|
|||
AddHandler(Setting_AutoFullscreen, new CSettingTypeApplication("","Auto Full Screen", (DWORD)false));
|
||||
AddHandler(Setting_AutoZipInstantSave,new CSettingTypeApplication("","Auto Zip Saves", (DWORD)true));
|
||||
AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("","Erase on default", (DWORD)true));
|
||||
AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("","Check Running", (DWORD)true));
|
||||
|
||||
AddHandler(Setting_RememberCheats, new CSettingTypeApplication("","Remember Cheats", (DWORD)false));
|
||||
AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("","Current Language",""));
|
||||
|
|
|
@ -21,6 +21,7 @@ CAdvancedOptionsPage::CAdvancedOptionsPage (HWND hParent, const RECT & rcDispay
|
|||
AddModCheckBox(GetDlgItem(IDC_ZIP),Setting_AutoZipInstantSave);
|
||||
AddModCheckBox(GetDlgItem(IDC_DEBUGGER),Debugger_Enabled);
|
||||
AddModCheckBox(GetDlgItem(IDC_REMEMBER_CHEAT),Setting_RememberCheats);
|
||||
AddModCheckBox(GetDlgItem(IDC_CHECK_RUNNING),Setting_CheckEmuRunning);
|
||||
AddModCheckBox(GetDlgItem(IDC_DISPLAY_FRAMERATE),UserInterface_DisplayFrameRate);
|
||||
|
||||
CModifiedComboBox * ComboBox;
|
||||
|
|
|
@ -20,6 +20,7 @@ class CAdvancedOptionsPage :
|
|||
COMMAND_ID_HANDLER_EX(IDC_ZIP,CheckBoxChanged)
|
||||
COMMAND_ID_HANDLER_EX(IDC_DEBUGGER,CheckBoxChanged)
|
||||
COMMAND_ID_HANDLER_EX(IDC_REMEMBER_CHEAT,CheckBoxChanged)
|
||||
COMMAND_ID_HANDLER_EX(IDC_CHECK_RUNNING,CheckBoxChanged)
|
||||
COMMAND_ID_HANDLER_EX(IDC_DISPLAY_FRAMERATE,CheckBoxChanged)
|
||||
COMMAND_HANDLER_EX(IDC_FRAME_DISPLAY_TYPE,LBN_SELCHANGE,ComboBoxChanged)
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ BEGIN
|
|||
END
|
||||
|
||||
IDD_Settings_Advanced DIALOGEX 0, 0, 231, 206
|
||||
STYLE DS_SETFONT | WS_CHILD
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||
BEGIN
|
||||
|
@ -324,8 +324,10 @@ BEGIN
|
|||
CONTROL "Automatically compress instant saves",IDC_ZIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,24,191,11
|
||||
CONTROL "Enable Debugger",IDC_DEBUGGER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,41,191,8
|
||||
CONTROL "Remember selected cheats",IDC_REMEMBER_CHEAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,57,191,8
|
||||
CONTROL "Frame rate display",IDC_DISPLAY_FRAMERATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,72,86,9
|
||||
COMBOBOX IDC_FRAME_DISPLAY_TYPE,101,71,99,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "Check if project64 is already running",IDC_CHECK_RUNNING,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,73,189,8
|
||||
CONTROL "Frame rate display",IDC_DISPLAY_FRAMERATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,88,86,9
|
||||
COMBOBOX IDC_FRAME_DISPLAY_TYPE,101,87,99,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_Settings_ShellInt DIALOGEX 0, 0, 231, 206
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#define IDR_POPUP 155
|
||||
#define IDR_CHEAT_MENU 160
|
||||
#define IDD_Lang_Select 161
|
||||
#define IDR_HTML_ABOUT 162
|
||||
#define IDD_Settings_GameRecompiler 162
|
||||
#define IDD_Settings_GamePlugin 163
|
||||
#define IDD_Settings_GameStatus 164
|
||||
|
@ -89,7 +88,6 @@
|
|||
#define IDC_HLE_AUDIO 1012
|
||||
#define IDC_SMM_CACHE 1012
|
||||
#define IDC_CASE_SENSITIVE 1012
|
||||
#define IDC_ROM_FIXEDAUDIO2 1012
|
||||
#define IDC_ROM_32BIT 1012
|
||||
#define IDC_INFO_COUNTRY 1013
|
||||
#define IDC_SHIFT 1013
|
||||
|
@ -97,7 +95,6 @@
|
|||
#define IDC_TLB_ENTRIES 1013
|
||||
#define IDC_SMM_DMA 1013
|
||||
#define IDC_UNKNOWN_ALIGN 1013
|
||||
#define IDC_ROM_FIXEDAUDIO3 1013
|
||||
#define IDC_DELAY_DP 1013
|
||||
#define IDC_INFO_CRC1 1014
|
||||
#define IDC_ASSIGNED_MENU_ITEM 1014
|
||||
|
@ -252,10 +249,8 @@
|
|||
#define IDC_DIR_FRAME3 1103
|
||||
#define IDC_DIR_FRAME4 1104
|
||||
#define IDC_DIR_FRAME5 1105
|
||||
#define IDC_ROMSEL_TEXT1 1111
|
||||
#define IDC_MAXROMS_TXT 1111
|
||||
#define IDC_ROMSEL_TEXT2 1112
|
||||
#define IDC_ROMSEL_TEXT3 1113
|
||||
#define IDC_MAXROMDIR_TXT 1113
|
||||
#define IDC_ROMSEL_TEXT4 1114
|
||||
#define IDC_UNMARK 1119
|
||||
|
@ -281,6 +276,7 @@
|
|||
#define IDC_ROMSEL_TEXT6 1144
|
||||
#define IDC_SCREEN_SAVER 1144
|
||||
#define IDC_ROM 1144
|
||||
#define IDC_CHECK_RUNNING 1144
|
||||
#define IDC_BASIC_MODE 1145
|
||||
#define IDC_JAP 1145
|
||||
#define IDC_PAL 1146
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include <Tlhelp32.h>
|
||||
//#pragma comment(linker,"/merge:.rdata=.text")
|
||||
|
||||
void FixUPXIssue ( BYTE * ProgramLocation )
|
||||
|
@ -244,6 +245,57 @@ void FixDirectories ( void )
|
|||
Directory.CreateDirectory();
|
||||
}
|
||||
|
||||
bool TerminatedExistingEmu()
|
||||
{
|
||||
bool bTerminated = false;
|
||||
bool AskedUser = false;
|
||||
DWORD pid = GetCurrentProcessId();
|
||||
|
||||
HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if(nSearch != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
PROCESSENTRY32 lppe;
|
||||
|
||||
memset(&lppe, 0, sizeof(PROCESSENTRY32));
|
||||
lppe.dwSize = sizeof(PROCESSENTRY32);
|
||||
stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension();
|
||||
|
||||
if (Process32First(nSearch, &lppe))
|
||||
{
|
||||
do
|
||||
{
|
||||
if(_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 ||
|
||||
lppe.th32ProcessID == pid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!AskedUser)
|
||||
{
|
||||
AskedUser = true;
|
||||
int res = MessageBox(NULL,stdstr_f("Project64.exe currently running\n\nTerminate pid %d now?",lppe.th32ProcessID).c_str(),"Terminate project64",MB_YESNO|MB_ICONEXCLAMATION);
|
||||
if (res != IDYES)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID);
|
||||
if(hHandle != NULL)
|
||||
{
|
||||
if (TerminateProcess(hHandle, 0))
|
||||
{
|
||||
bTerminated = true;
|
||||
} else {
|
||||
MessageBox(NULL,stdstr_f("Failed to terminate pid %d",lppe.th32ProcessID).c_str(),"Terminate project64 failed!",MB_YESNO|MB_ICONEXCLAMATION);
|
||||
}
|
||||
CloseHandle(hHandle);
|
||||
}
|
||||
} while (Process32Next(nSearch, &lppe));
|
||||
}
|
||||
CloseHandle(nSearch);
|
||||
}
|
||||
return bTerminated;
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
|
||||
{
|
||||
FixDirectories();
|
||||
|
@ -258,6 +310,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lps
|
|||
g_Settings = new CSettings;
|
||||
g_Settings->Initilize(AppName);
|
||||
|
||||
if (g_Settings->LoadBool(Setting_CheckEmuRunning) &&
|
||||
TerminatedExistingEmu())
|
||||
{
|
||||
delete g_Settings;
|
||||
g_Settings = new CSettings;
|
||||
g_Settings->Initilize(AppName);
|
||||
}
|
||||
|
||||
InitializeLog();
|
||||
|
||||
WriteTrace(TraceDebug,__FUNCTION__ ": Application Starting");
|
||||
|
|
Loading…
Reference in New Issue