# HG changeset patch
# User Benjamin Pollack <benja...@fogcreek.com>
# Date 1251150789 14400
# Branch stable
# Node ID 43fa88c8dae519cd3193c974e631c65b48074c95
# Parent  4555e191a783f462b7a14ff9873f5e4c07c3d00e
installer: automatically terminate taskbar process

diff --git a/contrib/win32/mercurial.iss b/contrib/win32/mercurial.iss
--- a/contrib/win32/mercurial.iss
+++ b/contrib/win32/mercurial.iss
@@ -18,7 +18,6 @@
 AppUpdatesURL=http://bitbucket.org/tortoisehg/stable/
 AppID=TortoiseHg
 AppContact=Steve Borho <st...@borho.org>
-AppMutex=thgtaskbar,Global\thgtaskbar
 OutputBaseFilename=TortoiseHg-{#VERSION}
 DefaultDirName={pf}\TortoiseHg
 SourceDir=..\..
@@ -106,6 +105,9 @@
 Root: HKLM; Subkey: Software\Mercurial; Flags: uninsdeletekey; ValueData: 
{app}\Mercurial.ini
 
 [Code]
+const
+  wm_Close = $0010;
+
 procedure FileExpandString(fn: String);
 var
     InFile: String;
@@ -133,7 +135,7 @@
  msg: String;
  CRLF: String;
 begin
- CRLF := chr(10) + chr(13);
+ CRLF := Chr(10) + Chr(13);
  Result := True;
 
  {abort installation if TortoiseHg 0.7 or earlier is installed}
@@ -169,4 +171,24 @@
   end; 
 end; 
 
+function PrepareToInstall: String;
+var
+  TaskbarWindow: HWND;
+  TaskbarMutex: String;
+begin
+  { Shut down the system tray if it is running }
+  TaskbarMutex := 'thgtaskbar,Global\thgtaskbar';
+  if CheckForMutexes(TaskbarMutex) then
+  begin
+    Result := 'The installer was unable to shut down TortoiseHg, and will now 
close.';
+    TaskbarWindow := FindWindowByWindowName('TortoiseHg RPC server');
+    if TaskbarWindow <> 0 then
+    begin
+      SendMessage(TaskbarWindow, wm_Close, 0, 0);
+      if not CheckForMutexes(TaskbarMutex) then
+        Result := '';
+    end;
+  end else Result := '';
+end;  
+
 #include "registry.iss"

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to