如何用API函数?(200分)

  • 主题发起人 主题发起人 tsingmei
  • 开始时间 开始时间
T

tsingmei

Unregistered / Unconfirmed
GUEST, unregistred user!
每当我调用ShellExecute时,总是不成功,请各位专家给出详细过程!谢谢!<br>编译器的话是。。。我又不懂!我已在uses里写了Shellapi,可下面调用时又不行,请指教!
 
大家快回答我嘛!
 
把你的代码贴出来看看。
 
HINSTANCE ShellExecute(<br>&nbsp; &nbsp; HWND hwnd, // handle to parent window<br>&nbsp; &nbsp; LPCTSTR lpOperation, // pointer to string that specifies operation to perform<br>&nbsp; &nbsp; LPCTSTR lpFile, // pointer to filename or folder name string<br>&nbsp; &nbsp; LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters <br>&nbsp; &nbsp; LPCTSTR lpDirectory, // pointer to string that specifies default directory<br>&nbsp; &nbsp; INT nShowCmd // whether file is shown when opened<br>&nbsp; &nbsp;); <br><br>例子:<br>&nbsp; OpenDialog1.Execute;<br>&nbsp; ShellExecute(Application.MainForm.Handle,<br>&nbsp; &nbsp; &nbsp; 'open',PChar(OpenDialog1.FileName),<br>&nbsp; &nbsp; &nbsp; nil,nil,SW_SHOW);<br><br>
 
大家好!请为我分析一下源码!错在那里呢?请为我写出正确源码好吗?<br>unit Unit1;<br>interface<br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls,ShellAPI;<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>{ Public declarations }<br>&nbsp; end;<br>var<br>&nbsp; Form1: TForm1;<br>&nbsp;function ShellExecute( HWND hwnd,LPCTSTR lpFile,LPCTSTR lpParameters,LPCTSTR lpDirectory,INT nShowCmd);stdcall;<br>implementation<br>{$R *.DFM}<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>ShellExecute(0, 'explore','http://huangwei2000.3322.net',0,0,SW_SHOWNORMAL);<br>end;<br>end.<br>
 
大家快给我回答嘛!
 
自己比较一下吧!<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows,Shellapi, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;ShellExecute(handle,nil,pchar('mailto:tsingmei@eLong.com'),nil,nil, sw_shownormal);<br><br>end;<br><br>end.<br>
 
接受答案了.
 
试试<br>ShellExecute(Application.MainForm.Handle, nil,<br>pchar('http://huangwei2000.3322.net'),0,0,SW_SHOWNORMAL);<br>现在手头没有编译器,不知对不对。<br><br>
 
后退
顶部