页面载入中....


一个可以实现任意EXE自启动的小玩艺
zslm 发表于 2008-7-2 2:22:00

program runAtOSStart;

uses
  Registry,windows,system;

{$R *.res}
var rightButtonRegistry,autoRunRegistry:TRegistry ;

function GetShortFileName(FileName: string): string; //转换长文件名为短文件名
var
  I: Integer;
  len:Integer;
  str:string;
begin
  //I := LastDelimiter(PathDelim + DriveDelim, FileName);
  len:=Length(FileName);
  i:=len;
  while  FileName[i]<>'\'do
  begin
    i:=i-1;
  end; 
  Result := Copy(FileName, I+1, len);
   end;
begin

  rightButtonRegistry :=TRegistry.Create;
  with rightButtonRegistry do
  begin
    RootKey :=HKEY_LOCAL_MACHINE ;
    if OpenKey( 'Software\classes\exefile\shell\runAtOSStart\command',true ) then
begin
    writestring('',system.ParamStr(0)+ ' "%1"');
    if paramcount=1 then
    begin
    autoRunRegistry:=tregistry.Create;
      with autoRunRegistry do
        begin
        RootKey :=HKEY_LOCAL_MACHINE ;
        OpenKey('SOFTWARE\Microsoft\windows\CurrentVersion\Run',true);
       WriteString(GetShortFileName(ParamStr(1)),ParamStr(1));           //在这个键中写入数据名称和数据数值
        CloseKey;
        end;
        CloseKey ;
     end;
     end;
  end;

end.


阅读全文 | 回复(0) | 引用通告 | 编辑
发表评论:
页面载入中....

 

页面载入中....

  公告
页面载入中....

  我的分类(专题)
页面载入中....
  最近日志
页面载入中....

  最新评论
页面载入中....

  留言板
页面载入中....

  链接

  Blog信息
页面载入中....





Powered by Oblog.