Author: remi
Date: 2009-02-12 16:27:24 +0100 (Thu, 12 Feb 2009)
New Revision: 3629

Added:
   software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.dpr
   software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.exe
Log:
* added a little server restarter

Added: 
software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.dpr
===================================================================
--- software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.dpr 
                        (rev 0)
+++ software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.dpr 
2009-02-12 15:27:24 UTC (rev 3629)
@@ -0,0 +1,88 @@
+program tuxhttpserver_restart;
+
+{$APPTYPE CONSOLE}
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ExtCtrls, Menus, Grids, ComCtrls,
+  shellApi,
+  tlhelp32,
+  Registry;
+
+const
+  TUXDROID_REGISTRY_PATH = 'SOFTWARE\Tuxdroid\TuxdroidSetup';
+
+var
+  tuxdroid_path : string;
+
+{**
+ *
+ *}
+function KillTask(ExeFileName: string): Integer;
+const
+  PROCESS_TERMINATE = $0001;
+var
+  ContinueLoop: BOOL;
+  FSnapshotHandle: THandle;
+  FProcessEntry32: TProcessEntry32;
+begin
+  Result := 0;
+  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
+  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
+  while Integer(ContinueLoop) <> 0 do
+  begin
+    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = 
UpperCase(ExeFileName)) or
+         (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then
+    begin
+      Result :=
+        Integer(
+          TerminateProcess(
+            OpenProcess(
+              PROCESS_TERMINATE,
+              BOOL(0),
+              FProcessEntry32.th32ProcessID
+            ),
+            0
+          )
+        );
+    end;
+    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
+  end;
+  CloseHandle(FSnapshotHandle);
+end;
+
+function getHttpServerPath : string;
+begin
+  result := '';
+  with TRegistry.Create do
+    try
+      RootKey := HKEY_LOCAL_MACHINE;
+
+      // From Tuxdroid setup
+      if OpenKey(TUXDROID_REGISTRY_PATH, False) then
+      begin
+        // Get tuxdroid installation path
+        result := ReadString('Install_Dir');
+        CloseKey;
+      end;
+    finally
+      Free;
+    end;
+end;
+
+begin
+  KillTask('pythonForTuxdroid.exe');
+
+  tuxdroid_path := getHttpServerPath;
+
+  Sleep(1500);
+
+  ShellExecute(
+    HWND(nil),
+    nil,
+    PChar(tuxdroid_path + '\softwares\python2.4\pythonForTuxdroid.exe'),
+    PChar('"' + tuxdroid_path + '\softwares\tuxhttpserver\tuxhttpserver.py"'),
+    PChar(tuxdroid_path + '\softwares\python2.4'),
+    SW_HIDE);
+end.


Property changes on: 
software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.dpr
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.exe
===================================================================
(Binary files differ)


Property changes on: 
software_suite_v2/tuxware/tuxhttpserver/trunk/src/tuxhttpserver_restart.exe
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream
Name: svn:keywords
   + Id


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to