API fuctions troubles

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!
YoniAsked:
Who is Participating?
 
msac_mConnect With a Mentor Commented:
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
 
ronit051397Commented:
Did you add to the uses  ShellApi?
0
 
msac_mCommented:
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
 
YoniAuthor Commented:
Thanks! it work perfectly now!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.