?
Solved

API fuctions troubles

Posted on 1998-10-28
4
Medium Priority
?
356 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 120 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

850 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