with Win32.Winbase; use Win32.Winbase;
with Win32; use type Win32.BOOL;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Conversion;
with interfaces.c; use interfaces.c;
with System;
procedure Create_Process is
function To_LPSTR is
new Ada.Unchecked_Conversion (System.Address, Win32.LPSTR);
Command_Line : Char_Array := To_C("explorer.exe");
Startup_Info : aliased STARTUPINFO;
Process_Info : aliased PROCESS_INFORMATION;
bResult : Win32.BOOL;
begin
put_line("Creating Process - Explorer");
Startup_Info.cb := (STARTUPINFOA'Size)/System.Storage_Unit;
Startup_Info.lpReserved := null;
Startup_Info.lpDesktop := null;
Startup_Info.lpTitle := null;
Startup_Info.dwFlags := 0;
Startup_Info.cbReserved2 := 0;
Startup_Info.lpReserved2 := null;
bResult := CreateProcess(
lpApplicationName => null,
lpCommandLine => To_LPSTR(Command_Line'Address),
lpProcessAttributes => null,
lpThreadAttributes => null,
bInheritHandles => Win32.False,
dwCreationFlags => 0,
lpEnvironment => System.Null_Address,
lpCurrentDirectory => null,
lpStartupInfo => Startup_Info'Unchecked_Access,
lpProcessInformation => Process_Info'Unchecked_Access );
if bResult /= Win32.False then
put_line("Process created.");
else
put_line("Process creation failed.");
end if;
end Create_Process;
|