Author: remi
Date: 2009-08-09 15:44:53 +0200 (Sun, 09 Aug 2009)
New Revision: 5304

Modified:
   
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/start.pas
Log:
* If smart-server is not started then alway start/restart TuxBox.

Modified: 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/start.pas
===================================================================
--- 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/start.pas
       2009-08-09 13:22:13 UTC (rev 5303)
+++ 
software_suite_v3/software/tool/tux_droid_browser_launcher/trunk/tux_droid_browser_launcher/start.pas
       2009-08-09 13:44:53 UTC (rev 5304)
@@ -81,6 +81,13 @@
 end;
 
 
+{#### Return true if Smart-Server is running ####}
+function isSmartServerRunning() : boolean;
+begin
+   result := isProcessRunning('pythonForTuxdroid.exe');
+end;
+
+
 {#### Set TuxBox 2.0 Foreground ####}
 procedure setForeground(wParam : Integer; mess : string);
 var
@@ -91,7 +98,34 @@
 end;
 
 
+function KillTask(exeName : 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(exeName)) or (UpperCase(FProcessEntry32.szExeFile) =
+        UpperCase(exeName))) then
+        Result := Integer(TerminateProcess(
+                          OpenProcess(PROCESS_TERMINATE,
+                                      BOOL(0),
+                                      FProcessEntry32.th32ProcessID),
+                                      0));
+       ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
+    end;
+  CloseHandle(FSnapshotHandle);
+end;
 
+
 {#### Start smart-core and TuxBox ####}
 procedure startAll(action : string);
 var
@@ -105,8 +139,24 @@
 
 {#### Main entry point ####}
 begin
-  if isTuxBoxRunning() then
+  if not isSmartServerRunning then
     begin
+      if isTuxBoxRunning then
+        KillTask('TuxBox.exe');
+      if ParamCount > 0 then
+        begin
+          if ParamStr(1) = 'minimize' then
+            begin
+              startAll('hide');
+            end;
+        end
+      else
+        begin
+          startAll('show');
+        end;
+    end
+  else if isTuxBoxRunning() then
+    begin
       try
         setForeground(0, 'WindowForegroundRequest');
       except
@@ -122,7 +172,7 @@
       end
     else
       begin
-      startAll('show');
+        startAll('show');
       end;
   Application.Terminate;
 end.


------------------------------------------------------------------------------
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
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to