zoukankan      html  css  js  c++  java
  • delphi 设置开机自动启动函数

    有些程序要设置为开机启动,所以自己写了个函数方便以后使用,供大家参考

    procedure TMainForm.SetAutoRun(ok: boolean);

    var
       Reg:TRegistry;       //首先定义一个TRegistry类型的变量Reg
    begin
       Reg:=TRegistry.Create;
       try                           //创建一个新键
         Reg.RootKey:=HKEY_LOCAL_MACHINE;     //将根键设置为HKEY_LOCAL_MACHINE
         Reg.OpenKey('SoftwareMicrosoftWindowsCurrentVersionRun',true);//打开一个键
         if ok then begin
            Reg.WriteString('SMS服务',ExpandFileName(ParamStr(0)));           //在Reg这个键中写入数据名称和数据数值
            ShowMessage('注册成功!'); 
         end
         else begin
            reg.DeleteValue('SMS服务');
            ShowMessage('删除成功!') 
         end;
         Reg.CloseKey;       //关闭键
       finally
         Reg.Free;
       end;
    end;

    例子:

    SetAutoRun(true);   //注册启动

    SetAutoRun(false);   //删除启动

  • 相关阅读:
    POJ 1095 Trees Made to Order 最详细的解题报告
    Producter and Consumer
    How to use the function of bind
    How to use the functions of apply and call
    Configurate vim tool
    #4713. 方程
    #4709. 树
    #4718. 管理
    #4710. 并
    #4707. 点分治
  • 原文地址:https://www.cnblogs.com/plug/p/4557217.html
Copyright © 2011-2022 走看看