Solved

API fuctions troubles

Posted on 1998-10-28
4
340 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

17 Experts available now in Live!

Get 1:1 Help Now