Skip to content

Commit 4b52051

Browse files
committed
Display error message if starting the generated installer fails
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7362 212acab6-be3b-0410-9dea-997c60f758d6
1 parent cccf842 commit 4b52051

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

Contrib/Makensisw/makensisw.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
650650
lstrcpy(str,g_sdata.input_script);
651651
str2=_tcsrchr(str,_T('\\'));
652652
if(str2!=NULL) *(str2+1)=0;
653-
ShellExecute(g_sdata.hwnd,_T("open"),str,NULL,NULL,SW_SHOWNORMAL);
653+
ShellExecuteWithErrorBox(hwndDlg, str);
654654
}
655655
return TRUE;
656656
}
@@ -750,20 +750,18 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
750750
case IDC_TEST:
751751
{
752752
if (g_sdata.output_exe) {
753-
ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.output_exe,NULL,NULL,SW_SHOWNORMAL);
753+
ShellExecuteWithErrorBox(hwndDlg, g_sdata.output_exe);
754754
}
755755
return TRUE;
756756
}
757757
case IDM_EDITSCRIPT:
758758
{
759759
if (g_sdata.input_script) {
760-
LPCTSTR verb = _T("open"); // BUGBUG: Should not force the open verb?
761-
HINSTANCE hi = ShellExecute(g_sdata.hwnd,verb,g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL);
762-
if ((UINT_PTR)hi <= 32) {
763-
TCHAR path[MAX_PATH];
764-
if (GetWindowsDirectory(path,sizeof(path))) {
765-
lstrcat(path,_T("\\notepad.exe"));
766-
ShellExecute(g_sdata.hwnd,verb,path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
760+
if (!ShellExecuteSilent(hwndDlg, g_sdata.input_script)) {
761+
TCHAR app[MAX_PATH];
762+
if (GetWindowsDirectory(app, COUNTOF(app))) {
763+
lstrcat(app,_T("\\notepad.exe"));
764+
ShellExecuteWithErrorBox(hwndDlg, app, g_sdata.input_script);
767765
}
768766
}
769767
}

Contrib/Makensisw/makensisw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline bool IsWin95() { return SupportsW95() && (GetVersion() & (0x8000FF
5757
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg, Anders Kjersem")
5858
#define DONATE _T("<A>Donate</A> to support NSIS development.")
5959
#define DONATEURL { 'h'|x,'t','t'|x,'p',':'|x,'/'|x,'/'|x,'n'|x,'s'|x,'i'|x,'s'|x,'.'|x,'s'|x,'f'|x,'.','n'|x,'e'|x,'t'|x,'/'|x,'r','/'|x,'D'|x,'o'|x,'n'|x,'a'|x,'t'|x,'e'|x,'\0' } // "Encrypted"
60-
#define DOCPATH "https://nsis.sourceforge.io/Docs/"
60+
#define DOCURL "https://nsis.sourceforge.io/Docs/"
6161
#define LOCALDOCS _T("\\NSIS.chm")
6262
#define ERRBOXTITLE 0 //_T("Error")
6363
#define NSISERROR _T("Unable to initialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe.")

Contrib/Makensisw/utils.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,19 @@ void ResetSymbols() {
700700
g_sdata.symbols = NULL;
701701
}
702702

703+
BOOL ShellExecuteWithErrorBox(HWND hWnd, LPCTSTR File, LPCTSTR Parameters) {
704+
SHELLEXECUTEINFO sei;
705+
sei.cbSize = sizeof(SHELLEXECUTEINFO);
706+
sei.fMask = SEE_MASK_FLAG_DDEWAIT;
707+
if (!(sei.hwnd = hWnd)) sei.fMask |= SEE_MASK_FLAG_NO_UI;
708+
sei.lpVerb = NULL;
709+
sei.lpFile = File;
710+
sei.lpParameters = Parameters;
711+
sei.lpDirectory = NULL;
712+
sei.nShow = SW_SHOW;
713+
return ShellExecuteEx(&sei);
714+
}
715+
703716
void FreeSpawn(PROCESS_INFORMATION *pPI, HANDLE hRd, HANDLE hWr) {
704717
if (pPI) {
705718
GetExitCodeProcess(pPI->hProcess, &pPI->dwProcessId);
@@ -824,12 +837,12 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
824837

825838
void ShowDocs() {
826839
TCHAR pathf[MAX_PATH],*path;
827-
GetModuleFileName(NULL,pathf,sizeof(pathf));
840+
GetModuleFileName(NULL,pathf,COUNTOF(pathf));
828841
path=_tcsrchr(pathf,_T('\\'));
829842
if(path!=NULL) *path=0;
830843
lstrcat(pathf,LOCALDOCS);
831-
if ((int)(INT_PTR) ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL) <= 32)
832-
ShellExecuteA(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
844+
if (!ShellExecuteSilent(g_sdata.hwnd, pathf))
845+
OpenUrlInDefaultBrowser(g_sdata.hwnd, DOCURL);
833846
}
834847

835848
TCHAR* BuildSymbols()

Contrib/Makensisw/utils.h

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ static inline UINT SizeOfStruct(const TOOLINFO&x) { return FIELD_OFFSET(TOOLINFO
6060
static inline UINT SizeOfStruct(const OPENFILENAME&x) { return sizeof(void*) < 8 ? 76 : sizeof(x); }
6161
UINT GetScreenBPP(HWND hWnd = NULL);
6262

63+
BOOL ShellExecuteWithErrorBox(HWND hWnd, LPCTSTR File, LPCTSTR Parameters = NULL);
64+
inline BOOL ShellExecuteSilent(HWND hWnd, LPCTSTR File) { return ShellExecuteWithErrorBox(NULL, File); }
6365
void FreeSpawn(PROCESS_INFORMATION *pPI, HANDLE hRd, HANDLE hWr);
6466
BOOL InitSpawn(STARTUPINFO &si, HANDLE &hRd, HANDLE &hWr);
6567

0 commit comments

Comments
 (0)