Selaa lähdekoodia

Attempt at making Windows uninstaller bail if DMDirc is running.

Didn't seem to work, but Java, DMDirc and my VM were acting oddly, so who knows!
Issue 441


git-svn-id: http://svn.dmdirc.com/trunk@3983 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 vuotta sitten
vanhempi
commit
a94254b805
1 muutettua tiedostoa jossa 32 lisäystä ja 3 poistoa
  1. 32
    3
      installer/windows/Uninstaller.dpr

+ 32
- 3
installer/windows/Uninstaller.dpr Näytä tiedosto

@@ -38,6 +38,31 @@ begin
38 38
 	CreateProcess(nil, PChar(sProgramToRun), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
39 39
 end;
40 40
 
41
+function CheckStdErr(sProgramToRun: String): Boolean;
42
+var
43
+        StartupInfo: TStartupInfo;
44
+	Pipe, Pipe2: THandle;
45
+        ProcessInfo: TProcessInformation;
46
+	BytesRead: Cardinal;
47
+        Buffer: array[0..255] of Char; 
48
+begin
49
+	CreatePipe(Pipe2, Pipe, nil, 0);
50
+
51
+        FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
52
+        with StartupInfo do begin
53
+                cb := SizeOf(TStartupInfo);
54
+                dwFlags := STARTF_USESHOWWINDOW;
55
+                wShowWindow := SW_SHOWNORMAL;
56
+		hStdError := Pipe;
57
+        end;
58
+
59
+        CreateProcess(nil, PChar(sProgramToRun), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
60
+
61
+	ReadFile(Pipe2, Buffer, 255, BytesRead, nil);
62
+
63
+	Result := BytesRead > 0;
64
+end;
65
+
41 66
 function KillDir(Dir: string): Integer;
42 67
 var
43 68
 	searchResult: TSearchRec;
@@ -140,10 +165,14 @@ begin
140 165
 		MessageBox(0, PChar('DMDirc has been uninstalled from "'+InstallDir+'".'), 'DMDirc Uninstaller', MB_OK);
141 166
 	end
142 167
 	else begin
143
-		TempDir := GetTempDirectory;
144
-		if MessageBox(0, PChar('This will uninstall DMDirc.'+#13#10+#13#10+'Please make sure DMDirc is not running before continuing, or some files might not get correctly removed.'+#13#10+#13#10+'Do you want to continue?'), 'DMDirc Uninstaller', MB_YESNO) = IDYES then begin
168
+MessageBox(0, PChar('java -jar ' + ExtractFileDir(paramstr(0)) + '/DMDirc.jar -e -v'), 'DMDirc Uninstaller', MB_OK + MB_ICONEXCLAMATION);
169
+
170
+		if checkStdErr('java -jar ' + ExtractFileDir(paramstr(0)) + 'DMDirc.jar -e -v') then begin
171
+	                TempDir := GetTempDirectory;
145 172
 			CopyFile(pchar(paramstr(0)), pchar(TempDir+'/uninstall.exe'), false);
146 173
 			Launch(TempDir+'/uninstall.exe '+ExtractFileDir(paramstr(0))+'\');
174
+		end else begin
175
+                        MessageBox(0, PChar('Uninstall Aborted - DMDirc is still running.'+#13#10+'Please close DMDirc before continuing'), 'DMDirc Uninstaller', MB_OK + MB_ICONEXCLAMATION);
147 176
 		end;
148 177
 	end;
149
-end.
178
+end.

Loading…
Peruuta
Tallenna