From: Pablo <pablittto@gmail.com>
Subject: Re: kill a process
Date: Wed, 23 Sep 2009 07:02:50 -0700 (PDT)
Date: 2009-09-23T07:02:50-07:00 [thread overview]
Message-ID: <3b7b70f3-29b7-4542-a5a3-2f83e3c19519@p15g2000vbl.googlegroups.com> (raw)
In-Reply-To: 46b358ce-ca3b-4c26-9f31-52040c3a1a1d@d21g2000vbm.googlegroups.com
On 22 set, 16:48, Gautier write-only <gautier_niou...@hotmail.com>
wrote:
> On 22 sep, 20:43, Pablo <pablit...@gmail.com> wrote:
>
> > On 21 set, 20:45, tmo...@acm.org wrote:
>
> > > >How can I kill a Windows process in Ada?
>
> > > type Process_Handles is new Interfaces.C.Unsigned;
> > > type Exit_Codes is new Interfaces.C.Unsigned;
> > > type Bool is new Interfaces.C.Int;
>
> > > function TerminateProcess(Process : Process_Handles;
> > > Exit_Code : Exit_Codes) return Bool;
> > > pragma Import(StdCall, TerminateProcess, "TerminateProcess");
>
> > Thanks!!
> > Now do you know how can I start two non-exiting Windows process in
> > paralell ? (something like command "&" in unix...)
>
> -->8------>8------>8------>8------>8------>8------>8----
> -----------
> -- Start --
> -----------
>
> procedure Start(
> File : in String;
> Parameter : in String := "";
> Minimized : in Boolean:= False
> )
> is
>
> C_Operation : aliased Interfaces.C.Char_Array :=
> Interfaces.C.To_C("open");
> C_Executable : aliased Interfaces.C.Char_Array :=
> Interfaces.C.To_C(File);
> C_Parameter : aliased Interfaces.C.Char_Array :=
> Interfaces.C.To_C(Parameter);
> -- Parts from Win32Ada:
> subtype PVOID is System.Address;
> subtype HANDLE is PVOID; -- winnt.h :144
> subtype HWND is HANDLE; -- windef.h :178
> subtype HINSTANCE is HANDLE;
> subtype INT is Interfaces.C.int; -- windef.h
> --
> Exe : HINSTANCE;
> pragma Warnings(Off, Exe);
> SW_SHOWNORMAL : constant := 1;
> SW_SHOWMINIMIZED : constant := 2;
> sw: constant array( Boolean ) of INT:=
> (SW_ShowNormal,
> SW_ShowMinimized);
> function GetFocus return HWND; -- winuser.h:2939
> pragma Import (Stdcall, GetFocus, "GetFocus");
> subtype CHAR is Interfaces.C.char;
> type PCCH is access constant CHAR;
> type PCHAR is access all CHAR;
> subtype LPCSTR is PCCH;
> subtype LPSTR is PCHAR;
> function ShellExecuteA
> (hwnd0 : HWND;
> lpOperation : LPCSTR;
> lpFile : LPCSTR;
> lpParameters : LPSTR;
> lpDirectory : LPCSTR;
> nShowCmd : INT)
> return HINSTANCE; -- shellapi.h:54
> pragma Import (Stdcall, ShellExecuteA, "ShellExecuteA"); --
> shellapi.h:54
> function ShellExecute
> (hwnd0 : HWND;
> lpOperation : LPCSTR;
> lpFile : LPCSTR;
> lpParameters : LPSTR;
> lpDirectory : LPCSTR;
> nShowCmd : INT)
> return HINSTANCE
> renames ShellExecuteA; -- shellapi.h:54
> begin
> Exe := Shellexecute
> (Hwnd0 => Getfocus,
> Lpoperation => C_Operation
> (C_Operation'First)'Unchecked_Access,
> Lpfile => C_Executable
> (C_Executable'First)'Unchecked_Access,
> Lpparameters => C_Parameter
> (C_Parameter'First)'Unchecked_Access,
> Lpdirectory => null,
> Nshowcmd => sw(minimized));
> end Start;
> -->8------>8------>8------>8------>8------>8------>8----
> HTH
> _________________________________________________________
> Gautier's Ada programming --http://sf.net/users/gdemont/
> NB: For a direct answer, e-mail address on the Web site!
Thanks, Gautier, it was exactly what I was looking for.
next prev parent reply other threads:[~2009-09-23 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-21 19:53 kill a process Pablo
2009-09-21 23:45 ` tmoran
2009-09-22 18:43 ` Pablo
2009-09-22 19:48 ` Gautier write-only
2009-09-23 14:02 ` Pablo [this message]
2009-09-22 21:45 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox