Board index » delphi » What am I doing wrong here? (Win API stuff)

What am I doing wrong here? (Win API stuff)

Please tell me what I am doing wrong here.  The declaration for
ShellExecute is in ShellAPI.  After I do syntax check on this unit, I get
the following errors:

Incompatible types: 'Variant' and 'PChar'

and the cursor is on the ShellExecute line, right on the 'P' of
ProgramPath.
I looked at the declaration of ShellExecute in ShellAPI.PAS and it indeed
declared as PChar.  So what am I doing wrong here?

unit Execute;

interface

uses
    ShellAPI, WinTypes, WinProcs;

implementation

procedure DoExecute;
var ProgramPath: PChar;

begin
     ProgramPath := '\windows\notepad.exe';
     ShellExecute(0,NULL,ProgramPath,NULL,NULL,SW_SHOWNORMAL);
end;
end.

--

Joseph I. Ceasar (Yossi)
CLS Computer Solutions

 

Re:What am I doing wrong here? (Win API stuff)


procedure DoExecute;
const
  ProgramPath: PChar = '\windows\notepad.exe';
begin
  ShellExecute(0,NULL,ProgramPath,NULL,NULL,SW_SHOWNORMAL);
end;

        Try this. Good luck!

Leo

Re:What am I doing wrong here? (Win API stuff)


Hello,

Use this dude:

     ShellExecute(0,NIL,ProgramPath,NIL,NIL,SW_SHOWNORMAL);

You were using NULL instead of NIL which, in D2, is a variant.

bly

Quote
j...@nyc.pipeline.com(Joseph I. Ceasar) wrote:

>Please tell me what I am doing wrong here.  The declaration for
>ShellExecute is in ShellAPI.  After I do syntax check on this unit, I get
>the following errors:

>Incompatible types: 'Variant' and 'PChar'

>and the cursor is on the ShellExecute line, right on the 'P' of
>ProgramPath.
>I looked at the declaration of ShellExecute in ShellAPI.PAS and it indeed
>declared as PChar.  So what am I doing wrong here?

>unit Execute;

>interface

>uses
>    ShellAPI, WinTypes, WinProcs;

>implementation

>procedure DoExecute;
>var ProgramPath: PChar;

>begin
>     ProgramPath := '\windows\notepad.exe';
>     ShellExecute(0,NULL,ProgramPath,NULL,NULL,SW_SHOWNORMAL);
>end;
>end.

>--

>Joseph I. Ceasar (Yossi)
>CLS Computer Solutions

Other Threads