|
@@ -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.
|