好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 codebutcher 于 2013-4-1 14:57 编辑
看到网上的一篇关于如何打开U盘最安全的方法的文章,于是我就想如何用编程的方式来实现它,由于还是新手,不懂这方便的,于是到网上找资料,都是零零碎碎的,拼拼凑凑的摸索了一会儿就实现了。
因为这还是很简单就能实现的,所以具体操作步骤就不详述了,接下来还是上代码吧,详见下面的:
//关键的部分我用红色的字体标注了
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
command:string;
begin
winexec('cmd.exe /c start c:\',SW_HIDE);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
winexec('cmd.exe /c start d:\',SW_HIDE);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
winexec('cmd.exe /c start e:\',SW_HIDE);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
winexec('cmd.exe /c start f:\',SW_HIDE);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
winexec('cmd.exe /c start g:\',SW_HIDE);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
winexec('cmd.exe /c start h:\',SW_HIDE);
end;
end.
这里是用winexec来实现的,SW_HIDE用来实现隐藏CMD.EXE DOS命令提示符窗口执行代码的目的。
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|