codebutcher 发表于 2013-4-1 14:53

用winexec来实现打开硬盘分区

本帖最后由 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命令提示符窗口执行代码的目的。

edison7712 发表于 2013-4-2 12:30

好东西。帮楼主顶下

codebutcher 发表于 2013-4-2 17:46

好,谢谢楼上的朋友。
页: [1]
查看完整版本: 用winexec来实现打开硬盘分区