* kill a process @ 2009-09-21 19:53 Pablo 2009-09-21 23:45 ` tmoran 0 siblings, 1 reply; 6+ messages in thread From: Pablo @ 2009-09-21 19:53 UTC (permalink / raw) How can I kill a Windows process in Ada? Say us, if I have a service like myservice.exe running and I have to kill it. Tks ^ permalink raw reply [flat|nested] 6+ messages in thread
* re: kill a process 2009-09-21 19:53 kill a process Pablo @ 2009-09-21 23:45 ` tmoran 2009-09-22 18:43 ` Pablo 0 siblings, 1 reply; 6+ messages in thread From: tmoran @ 2009-09-21 23:45 UTC (permalink / raw) >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"); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: kill a process 2009-09-21 23:45 ` tmoran @ 2009-09-22 18:43 ` Pablo 2009-09-22 19:48 ` Gautier write-only 2009-09-22 21:45 ` tmoran 0 siblings, 2 replies; 6+ messages in thread From: Pablo @ 2009-09-22 18:43 UTC (permalink / raw) 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...) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: kill a process 2009-09-22 18:43 ` Pablo @ 2009-09-22 19:48 ` Gautier write-only 2009-09-23 14:02 ` Pablo 2009-09-22 21:45 ` tmoran 1 sibling, 1 reply; 6+ messages in thread From: Gautier write-only @ 2009-09-22 19:48 UTC (permalink / raw) 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! ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: kill a process 2009-09-22 19:48 ` Gautier write-only @ 2009-09-23 14:02 ` Pablo 0 siblings, 0 replies; 6+ messages in thread From: Pablo @ 2009-09-23 14:02 UTC (permalink / raw) 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: kill a process 2009-09-22 18:43 ` Pablo 2009-09-22 19:48 ` Gautier write-only @ 2009-09-22 21:45 ` tmoran 1 sibling, 0 replies; 6+ messages in thread From: tmoran @ 2009-09-22 21:45 UTC (permalink / raw) >Now do you know how can I start two non-exiting Windows process in >paralell ? (something like command "&" in unix...) Look in your handy Windows docs for CreateProcess. You may also want GetStartupInfo to help fill in some of the startupinfo parameters. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-09-23 14:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 2009-09-22 21:45 ` tmoran
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox