Solved

API fuctions troubles

Posted on 1998-10-28
4
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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