谁能告诉我如何调用这个东东?(100分)

  • 主题发起人 主题发起人 树熊133
  • 开始时间 开始时间

树熊133

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能告诉我如何调用系统的时钟和计算器,我的系统是win2000。
 
用ShellExecute
 
用法:<br>handle是integer<br>ShellExecute(handle, 'open', pchar('mailto:Leskil@public.sj.he.cn'), nil, nil, SW_SHOWNORMAL);
 
该函数的头文件是什么?
 
没有头文件,在uses中加入shellapi,<br>他是封装在dll中的函数,是微软的,我们在delphi中调用。
 
那是直接在uses中写入ShellExecute,然后在程序中调用吗?但好象不行的,编译不同过,<br>好象是在uses中的ShellExecute处出错。
 
加到这个地方如下<br>unit DTluyin;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; Grids, ComCtrls, Menus, frstatus, ExtCtrls,Tw8VW,LYThread,AdvHint,<br>&nbsp; AdvComm, Db, DBTables, StdCtrls, UserMan,UserLog,[red]shellapi[/red], WebLabel;<br><br>type<br>&nbsp; TLYMain = class(TForm)<br>&nbsp; &nbsp; StatusGrid: TDrawGrid;<br>&nbsp; &nbsp; MainMenu1: TMainMenu;<br>&nbsp; &nbsp; N1: TMenuItem;<br>&nbsp; &nbsp; Timer1: TTimer;<br>&nbsp; &nbsp; N3: TMenuItem;<br>&nbsp; &nbsp; N4: TMenuItem;<br>&nbsp; &nbsp; N5: TMenuItem;<br>&nbsp; &nbsp; N6: TMenuItem;<br>&nbsp; &nbsp; N7: TMenuItem;<br>&nbsp; &nbsp; N8: TMenuItem;<br>&nbsp; &nbsp; N9: TMenuItem;<br>&nbsp; &nbsp; StatusBar: TLyyStatusBar;<br>&nbsp; &nbsp; imgDisable: TImage;<br>&nbsp; &nbsp; imgUnHook: TImage;<br>&nbsp; &nbsp; imgHook: TImage;<br>&nbsp; &nbsp; InitMenu: TMenuItem;
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls,shellapi;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(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; ShellExecute(handle, 'open', pchar('mailto:Leskil@public.sj.he.cn'), nil, nil, SW_SHOWNORMAL);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>ShellExecute(handle, 'open', pchar('C:/WINNT/System32/calc.exe'), nil, nil, SW_SHOWNORMAL);<br>end;<br><br>end.
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls,shellapi;<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;ShellExecute(handle, 'open', 'calc.exe', nil, nil, SW_SHOWNORMAL);<br>end;<br><br>end.<br>
 
谢谢各位,再问一下,系统时间的路径是什么。
 
调用时钟<br>winexec('RunDLL32.exe Shell32.dll,Control_RunDLL TimeDate.cpl,,0',sw_shownormal);<br>调用计算器<br>shellexecute(handle,'open',pchar('calc.exe'),nil,nil,sw_shownormal);
 
同意j_shen2000
 
这样更简单,而且不用加入其它单元。<br>winexec('rundll32.exe shell32.dll,Control_RunDLL timedate.cpl',9);//时间<br>winexec('calc.exe',sw_show);//计算器
 
j_shen2000说得够清楚啦!<br>
 
多人接受答案了。
 
后退
顶部