comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Re: kill a process
Date: Tue, 22 Sep 2009 12:48:28 -0700 (PDT)
Date: 2009-09-22T12:48:28-07:00	[thread overview]
Message-ID: <46b358ce-ca3b-4c26-9f31-52040c3a1a1d@d21g2000vbm.googlegroups.com> (raw)
In-Reply-To: de7b4cc6-5f94-42cb-9a34-3f0e020f3f7b@m20g2000vbp.googlegroups.com

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!



  reply	other threads:[~2009-09-22 19:48 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 [this message]
2009-09-23 14:02       ` Pablo
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