Solved

API fuctions troubles

Posted on 1998-10-28
4
339 Views
Last Modified: 2010-04-03
I am using some API functions with no problem. I just type them and delphi recognizes them and their syntax (just like native delphi functions). But when I try to use other functions they won't work. For instance Winexe is a function that delphi 4 recognizes but when I try to use shellexecute and I do the syntax right I get an "undeclared identifier "ShellExecute" error. Can anyone tell me what's the problem and how to solve it?
Thanks!
0
Comment
Question by:Yoni
  • 2
4 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1344767
Did you add to the uses  ShellApi?
0
 

Accepted Solution

by:
msac_m earned 30 total points
ID: 1344768
Hi  Yoni
  The WinExec Function is defined in the Windos.pas unit, as;

function WinExec(lpCmdLine: LPCSTR; uCmdShow: UINT): UINT; stdcall;
function WinExec; external kernel32 name 'WinExec';

and in each new application you create, the window unit is automatically included in the uses clause, so you can call the WinExec without problem. But some api functions are declared in other unþts which may not be included when the application is created For instance ShellExec. This function is defined another unit namely, ShellApi.Pas as foolows:
function ShellExecute(hWnd: HWND; Operation, FileName, Parameters,  Directory: PChar; ShowCmd: Integer): HINST; stdcall;
function ShellExecute; external shell32 name 'ShellExecuteA';

so to use it without problem, you must add the shellapi in your uses clause.

Regards,



,

So to use it
0
 

Expert Comment

by:msac_m
ID: 1344769
Hi ronit,

   Sorry for submitting as answer, beacuse I did not see your comment. While I was writing my answer you must have posted your comment. Sorry ..

Regards,

0
 

Author Comment

by:Yoni
ID: 1344770
Thanks! it work perfectly now!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
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…

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

18 Experts available now in Live!

Get 1:1 Help Now