Re: [BLACKBOX] starting and stopping application from BlackBox

From: [at]} <Andrew>
Date: Fri, 14 May 2010 09:10:10 +0100


Thanks for this Werner.
 
Andrew


On 13 May 2010 16:50, Werner Braun <wb{([at]})nowhere.xy


Hi,


> Hello BlackBox peoples,
>
> There is a procedure in the HostDialog called Start to start an
> application from within BlackBox. Is there a
> equivalent procedure to this to close an application. One obvious problem is
> knowing which applications have
> been started by BlackBox.



try module O3bbWin of our Tool-Package
http://www.o3-software.de <http://www.o3-software.de/>

or just this:

IMPORT
       HostFiles,
       WinApi;

TYPE
       Process* = POINTER TO LIMITED RECORD
               hProcess, hThread : WinApi.HANDLE;
       END;


PROCEDURE (p : Process) Terminate*,NEW;
       VAR res, exitCode : INTEGER;
       BEGIN
               IF p.hProcess # 0 THEN
                       res := WinApi.TerminateProcess(p.hProcess,exitCode);
                       res := WinApi.CloseHandle(p.hProcess);
                       res := WinApi.CloseHandle(p.hThread);
                       p.hProcess := 0;
               END;
       END Terminate;

PROCEDURE ProcessCreate* (commandLine : ARRAY OF CHAR) : Process;
       VAR si : WinApi.STARTUPINFOW; pi : WinApi.PROCESS_INFORMATION;
               res : INTEGER; proc : Process;
       BEGIN
               WinApi.GetStartupInfoW(si); (* get information about the current process *)
               si.wShowWindow := WinApi.SW_SHOWNORMAL; (* activate and display the window *)
                       (* Docu: An application should specify this flag when displaying the window for the first time. *)
               res := WinApi.CreateProcessW(NIL,commandLine,NIL,NIL,WinApi.FALSE,{},0,NIL,si,pi);
                       (* Docu: lpCommandLine The Unicode version of this function, CreateProcessW, can modify the contents of this string.
                               Therefore, this parameter cannot be a pointer to read-only memory ...
                       *)
               ASSERT(res # 0,100);
               NEW(proc);
               proc.hProcess := pi.hProcess;
               proc.hThread := pi.hThread;
               RETURN proc
       END ProcessCreate;





mit freundlichen Grüssen

Werner Braun

Mobil +49 (0)178 145 8768 * Fon +49 (0)431 556 8907-1 * Fax +49 (0)431 556 8907-9

O³ Software GmbH & Co. KG * Franziusallee 131 * D-24148 Kiel * Germany
Sitz der Gesellschaft Kiel * HR Amtsgericht Kiel HRA 6418 KI
Persönlich haftende Gesellschafterin O³ Software GmbH * HR Amtsgericht Kiel HRB 10335 KI * Geschäftsführer Werner Braun


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Fri May 14 2010 - 10:10:10 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:32 UTC