谁能提供开始菜单运行命令的执行方法?(100分)

  • 主题发起人 主题发起人 xxljishiben
  • 开始时间 开始时间
X

xxljishiben

Unregistered / Unconfirmed
GUEST, unregistred user!
我的意思是,开始菜单的运行命令,调用的哪个或者哪几个api函数,以及他们的控制流程是什么样子的。
 
抄的别人的,肯定对你有帮助.模拟开始菜单Run的功能.<br>---<br>netke (2001-11-28 9:26:00) &nbsp;<br>unit RunDialog;<br>interface<br>uses<br> &nbsp;Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br>type<br> &nbsp;TRunDialog = class(TComponent)<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp; &nbsp;FDescription: String;<br> &nbsp; &nbsp;FHideBrowseButton: Boolean;<br> &nbsp; &nbsp;FIcon: TIcon;<br> &nbsp; &nbsp;FInitialDir: String;<br> &nbsp; &nbsp;FTitle: String;<br> &nbsp; &nbsp;procedure SetDescription(Value: String);<br> &nbsp; &nbsp;procedure SetHideBrowseButton(Value: Boolean);<br> &nbsp; &nbsp;procedure SetIcon(Value: TIcon);<br> &nbsp; &nbsp;procedure SetInitialDir(Value: String);<br> &nbsp; &nbsp;procedure SetTitle(Value: String);<br> &nbsp;protected<br> &nbsp; &nbsp;{ Protected declarations }<br> &nbsp; &nbsp;constructor Create(AOwner: TComponent); override;<br> &nbsp; &nbsp;destructor Destroy; override;<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp; &nbsp;procedure Execute;<br> &nbsp;published<br> &nbsp; &nbsp;{ Published declarations }<br> &nbsp; &nbsp;property Description: String read FDescription write SetDescription;<br> &nbsp; &nbsp;property HideBrowseButton: Boolean read FHideBrowseButton write SetHideBrowseButton;<br> &nbsp; &nbsp;property Icon: TIcon read FIcon write SetIcon;<br> &nbsp; &nbsp;property InitialDir: String read FInitialDir write SetInitialDir;<br> &nbsp; &nbsp;property Title: String read FTitle write SetTitle;<br> &nbsp;end;<br><br>var<br> Flags: LongInt = 0;<br><br>const<br> RFF_NOBROWSE = 1;<br><br>procedure Register;<br><br>implementation<br>procedure RunFileDlgA(OwnerWnd: HWND; Icon: HICON; lpstrDirectory: PAnsiChar;<br> lpstrTitle: PAnsiChar; lpstrDescription: PAnsiChar; Flags: LongInt); stdcall;<br> external 'Shell32.dll' index 61;<br>constructor TRunDialog.Create(AOwner: TComponent);<br>begin<br> inherited Create(AOwner);<br> FIcon := TIcon.Create;<br>end;<br><br>destructor TRunDialog.Destroy;<br>begin<br> FIcon.Free;<br> inherited Destroy;<br>end;<br><br>procedure TRunDialog.Execute;<br>begin<br>if FHideBrowseButton = True then<br> begin<br> &nbsp;Flags := Flags or RFF_NOBROWSE;<br> end;<br>RunFileDlgA(0,FIcon.Handle,PChar(FInitialDir),PChar(FTitle),PChar(FDescription),Flags);<br>end;<br><br>procedure TRunDialog.SetDescription(Value: String);<br>begin<br>if Value &lt;&gt; FDescription then<br> begin<br> &nbsp;FDescription := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetHideBrowseButton(Value: Boolean);<br>begin<br>if Value &lt;&gt; FHideBrowseButton then<br> begin<br> &nbsp;FHideBrowseButton := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetIcon(Value: TIcon);<br>begin<br>if Value &lt;&gt; FIcon then<br> begin<br> &nbsp;FIcon.Assign(Value);<br> end;<br>end;<br><br>procedure TRunDialog.SetInitialDir(Value: String);<br>begin<br>if Value &lt;&gt; FInitialDir then<br> begin<br> &nbsp;FInitialDir := Value;<br> end;<br>end;<br><br>procedure TRunDialog.SetTitle(Value: String);<br>begin<br>if Value &lt;&gt; FTitle then<br> begin<br> &nbsp;FTitle := Value;<br> end;<br>end;<br><br>procedure Register;<br>begin<br> &nbsp;RegisterComponents('Dialogs', [TRunDialog]);<br>end;<br>end.
 
uses Shell32_TLB; //导入类型库:shell32.dll;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;AAA:TShell;<br>begin<br> &nbsp;AAA:=TShell.Create(Application);<br> &nbsp;AAA.FileRun;<br>end;
 
你为什么要这样做?自己做个不就行了?开始菜单实际上调用shellexecute来运行程序的<br>不过具体用shellexecute的哪个版本,是根据操作系统决定的
 
多人接受答案了。
 
出差刚回来,好久没上来看贴了,所以, 先给分,再读程序!
 
后退
顶部