Lazarus

Installation => PDAs and Smartphones => Topic started by: leandrojcbh on December 05, 2013, 05:49:51 pm

Title: How i use CreateProcess ?
Post by: leandrojcbh on December 05, 2013, 05:49:51 pm
Hello!

I try to use in Lazarus:

uses

shellapi, process, windows;


(CreateProcess(pwidechar('\program files\test\hello.exe'), Nil, Nil, Nil,
  False, CREATE_NEW_CONSOLE, Nil, Nil, StartupInfo, ProcessInformation));

Error:

unit1.pas(40,71) Error: Identifier not found "ProcessInformation" !

Help!
Title: Re: How i use CreateProcess ?
Post by: marcov on December 05, 2013, 06:00:38 pm
processinformation afaik is a variable that you must declare. See MSDN
Title: Re: How i use CreateProcess ?
Post by: leandrojcbh on December 05, 2013, 06:33:35 pm
But How?

I want do execute a .exe file!
Can you help!

I´m lost!
Title: Re: How i use CreateProcess ?
Post by: leandrojcbh on December 05, 2013, 06:35:15 pm
This is my prog:


unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Dialogs, Menus,
  StdCtrls, Buttons, ExtCtrls, ComCtrls, DbCtrls, shellapi, process,
  windows, winceproc, winceint;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  ProcessInformation:tProcessInformation;

begin

  CreateProcess(pwidechar('volume.exe'), Nil, Nil, Nil,
  False, CREATE_NEW_CONSOLE, Nil, Nil, StartupInfo, ProcessInformation);
end;

end.


What is wrong?
Title: Re: How i use CreateProcess ?
Post by: leandrojcbh on December 05, 2013, 08:41:13 pm
I get it!

Thanks!!!
Title: Re: How i use CreateProcess ?
Post by: tranminhchien on December 29, 2013, 01:55:54 pm
But How?

I want do execute a .exe file!
Can you help!

I´m lost!
if you just want to execute a .exe file, you can use shellExecute for more simplier. For example :

ShellExecute(0, nil, 'notepad.exe', nil, nil, 1);

this function is included in unit shellapi :)
TinyPortal © 2005-2018