comp.lang.ada
 help / color / mirror / Atom feed
From: "Simon Johnston" <skj@acm.org>
Subject: Win32Ada and CreateProcess
Date: 1997/07/10
Date: 1997-07-10T00:00:00+00:00	[thread overview]
Message-ID: <01bc8cfd$18b968f0$0100007f@skj_nb_02> (raw)


Can anyone help here. I am using ObjectAda 7.1 and am trying to use the
Win32 API CreateProcess function. I have copied code from an existing C++
application which I know works but every time it runs I get a Win32 error
2, which is ERROR_FILE_NOT_FOUND. Included below is the beginning of the
package including the relevant procedure. This is beginning to annoy me so
rather than tear out my hair I thought I would ask around.


with System; use System;

with Interfaces.C; use Interfaces.C;

with Win32; use Win32;
with Win32.Winnt; use Win32.Winnt;
with Win32.Winbase; use Win32.Winbase;
with Win32.Winuser; use Win32.Winuser;

package body Process_Control is
    
    function memset
       (Destination : in Win32.PVOID;
        Fill        : in Interfaces.C.int;
        Length      : in Interfaces.C.size_t) 
        return Win32.PVOID;
    pragma Import(C, memset, "memset");
    
    procedure Execute
        (Command_Line : in String;
         Environment  : in String  := "";
         Process      : out Process_Id) is
        dwError  : DWORD;
        fCreate  : Win32.BOOL;
        StartInfo: aliased STARTUPINFO;
        ProcInfo : aliased PROCESS_INFORMATION;
        pTemp    : PVOID;
    begin
        
        pTemp := memset(StartInfo'Address, 0, StartInfo'Size / 8);
        
        StartInfo.cb          := StartInfo'Size / 8;
        StartInfo.wShowWindow := SW_SHOW;

        fCreate := CreateProcess(lpApplicationName    => null,
            			lpCommandLine        => Win32.Addr(Command_Line),
                                 		lpProcessAttributes  => null,
                                 		lpThreadAttributes   => null,
                                 		bInheritHandles      => Win32.TRUE,
                                 		dwCreationFlags      =>
(CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS),
                                 		lpEnvironment        => null,
                                 		lpCurrentDirectory   => null,
                                 		lpStartupInfo        =>
StartInfo'Unchecked_Access,
                                 		lpProcessInformation =>
ProcInfo'Unchecked_Access);
	    if fCreate = Win32.FALSE then
            dwError := GetLastError;
			raise Not_Executable;
        end if;                                     
    end Execute;

with StandardDisclaimer; use StandardDisclaimer;
package Sig is
--,--------------------------------------------------------------.
--|Simon K. Johnston - Windows NT Consultant |Dimensions + Ltd   |
--|------------------------------------------|150 Minories       |
--|Telephone: +44 (0)171 2642144             |London             |
--|Fax      : +44 (0)171 2642145             |EC3N 1LS           |
--|Mail URI : mailto:skj@acm.org             |United Kingdom     |
--|WWW URI  : http://www.DimensionsPlus.Com  |                   |
--`--------------------------------------------------------------'
end Sig;





             reply	other threads:[~1997-07-10  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-10  0:00 Simon Johnston [this message]
1997-07-11  0:00 ` Win32Ada and CreateProcess Pascal Obry
1997-07-11  0:00 ` Kevin Radke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox