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);   //删除启动

  • 相关阅读:
    2017icpc青岛
    训练赛
    CF1598F
    CF1581
    CF1594
    CF1581D
    codeforces round 746 div2 C-E
    How I Think About Learning
    Linux Sysadmin Basics 4.1 -- Filtering Output and Finding Things (&&, cut, sort, uniq, wc, grep)
    Linux Sysadmin Basics 04 -- Shell Features -- Pipes and Redirection
  • 原文地址:https://www.cnblogs.com/plug/p/4557217.html
Copyright © 2011-2022 走看看