Skip to content

Commit

Permalink
added command line mutex checking (fix #750)
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypp committed Aug 25, 2020
1 parent ccfe0cb commit 094bf04
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5030,8 +5030,14 @@ INT APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdL

if (_r_app_initialize (APP_NAME, APP_NAME_SHORT, APP_VERSION, APP_COPYRIGHT))
{
HANDLE hcmdmutex = NULL;
PR_STRING hcmdname = _r_format_string (L"%sCmd", _r_app_getnameshort ());

// parse arguments
if (!_r_mutex_isexists (hcmdname))
{
_r_mutex_create (hcmdname, &hcmdmutex);

INT numargs;
LPWSTR* arga = CommandLineToArgvW (_r_sys_getimagecommandline (), &numargs);

Expand Down Expand Up @@ -5096,12 +5102,24 @@ INT APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdL
}
else
{
_r_mutex_destroy (&hcmdmutex);

return ERROR_ACCESS_DENIED;
}

_r_mutex_destroy (&hcmdmutex);

return ERROR_SUCCESS;
}
}

_r_obj_dereference (hcmdname);

_r_mutex_destroy (&hcmdmutex);
}
else
{
return ERROR_SUCCESS;
}

if (_r_app_createwindow (IDD_MAIN, IDI_MAIN, &DlgProc))
Expand Down

0 comments on commit 094bf04

Please sign in to comment.