Solved

I need ShellAPI help for my unit

Posted on 2001-08-31
8
408 Views
Last Modified: 2010-05-18
I have a small unit 'ExeMod.pas' and in the Initialization section I have code like this


initialization
begin
ShellExecute(Handle, 'open', PChar('My.exe'), PChar('-a'), nil, SW_SHOW);
end;
end.

I put ShellAPI in the unit's uses clause
but when I try to run a program that uses
ExeMod.pas I get this error

Undeclared identifier 'Handle'

what silly little thing am I forgetting to do...or what am I doing wrong?
:-)
0
Comment
Question by:Gwena
8 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 6447231
Looks like you don't need the Handle at all. Use 0 or nil instead.
0
 
LVL 22

Expert Comment

by:mnasman
ID: 6447242
seems that you don't use forms, so the contorl unit not included in the uses clause
0
 
LVL 5

Author Comment

by:Gwena
ID: 6447252
Hi :-)

 adding control to the uses does not help :-(
 setting Handle to 0 does seem to work :-)

But It's late and I'm groggy (must be that long island tea that guy got me :-)

I will check out using 0 to replace Handle a bit more in the morning :-)
0
 
LVL 17

Expert Comment

by:inthe
ID: 6447266
just to add ,used in the usual delphi context
(ie in some procedure of a form) "handle"  would refer to the form1.handle property

for instance

procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(handle));
showmessage(inttostr(form1.Handle));
end;

would both show same result
so to use a 0 a nick said will be fine

 from win32 help about the hwnd param of shellexecute:
This window receives any message boxes that an application produces. For example, an application may report an error by producing a message box.

if that functionality was needed you would probably use createprocess anyway..
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:d32coder
ID: 6447686
Try using
Application.Handle
instead.

Don
0
 
LVL 5

Author Comment

by:Gwena
ID: 6447784


  Your solution works fine... so here's your points
Thanks a bunch :-)
0
 
LVL 5

Author Comment

by:Gwena
ID: 6447792
Hi inthe
  Thanks for the extra info about handles... handles still seem a bit mysterious to me :-)
0
 
LVL 5

Author Comment

by:Gwena
ID: 6447796
Hi d32coder

 Application.handle seems to work fine as well... thanks for the info :-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now