Using ShellExecuteEx in D5 HWND not defined in TShellExecuteInfo structure?

In order to ShellExec another process or application that requires increased permission on Vista I am using the procedure below. by adding 'runas' to the lpVerb, Vista will ask for admin rights.

Now, HWND is "supposed" to be defined in the  TShellExecuteInfo structure. But I get an "Undeclared Identifier: HWND" error that I do not understand.

This is D5 and on D2006, the same thing! In essence it "does not contain a member named HWND". But it should according to all of the documentation.

Am I missing something?

It does work OK with it remmed out... so I am just curious.

Thanks

John
procedure VistaExecElevated(FileName, CLParams, Dir : String);
var
 shExecInfo : TShellExecuteInfo;
begin
 if FileName <> '' then
  begin
   FillChar(shExecInfo, SizeOf(shExecInfo), 0);
   shExecInfo.cbSize := SizeOf(shExecInfo);
   shExecInfo.fMask  := Null;
   //shExecInfo.HWND := Nil; //Errors as HWND not found
   shExecInfo.lpVerb := PChar('runas');
   shExecInfo.lpFile := PChar(FileName);
   if CLParams <> '' then
    shExecInfo.lpParameters := PChar(CLParams)
     else
      shExecInfo.lpParameters := Nil;
   if Dir <> '' then
    shExecInfo.lpDirectory := pchar(Dir)
     else
      shExecInfo.lpDirectory := Nil;
   shExecInfo.nShow := SW_SHOW;
   shExecInfo.hInstApp := NULL;
   ShellExecuteEx(@shExecInfo);
  end;
end;

Open in new window

LVL 18
JohnjcesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ziolkoCommented:
HWND is type defined in windows.pas as WHND = type LongWord; what you trying to use should be Wnd;

  _SHELLEXECUTEINFOA = record
    cbSize: DWORD;
    fMask: ULONG;
    Wnd: HWND;  << here Wnd is of type HWND
    lpVerb: PAnsiChar;
    lpFile: PAnsiChar;
    lpParameters: PAnsiChar;
    lpDirectory: PAnsiChar;
    nShow: Integer;
    hInstApp: HINST;
    { Optional fields }
    lpIDList: Pointer;
    lpClass: PAnsiChar;
    hkeyClass: HKEY;
    dwHotKey: DWORD;
    hIcon: THandle;
    hProcess: THandle;
  end;


ziolko.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ziolkoCommented:
oops of course
HWND = type LongWord;

ziolko.
0
JohnjcesAuthor Commented:
Thanks!

I couldn't find it ShellAPI.pas and never even thought about looking in Windows.pas!

That solves that question!

John
0
JohnjcesAuthor Commented:
Thanks again!
0
ziolkoCommented:
yup sometimes most obvious solutions are hardest to find:)

ziolko.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.