zoukankan      html  css  js  c++  java
  • delphi 开机自动运行代码

    unit Unit1;
    //download by http://www.codefans.net
    interface

    uses
      Windows,Registry, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

    type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.DFM}
    procedure SetAutorun(aProgTitle,aCmdLine: string; aRunOnce: boolean );
    var
      hKey: string;
      hReg: TRegIniFile;
    begin
      if aRunOnce then
      //程序只自动运行一次
        hKey := 'Once'
      else
        hKey := '';
      hReg := TRegIniFile.Create('');
      //TregIniFile类的对象需要创建
      hReg.RootKey := HKEY_LOCAL_MACHINE;
      //设置根键
      hReg.WriteString('SoftwareMicrosoftWindowsCurrentVersionRun'
                      + hKey + #0,
                      aProgTitle,
                      //程序名称,可以为自定义值
                      aCmdLine );
                      //命令行数据,必须为该程序的绝对路径+程序完整名称
      hReg.destroy;
      //释放创建的hReg
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
     SetAutorun(Application.Title,application.ExeName,false);
    end;

    end.

  • 相关阅读:
    手打AC的第2道数位DP:BZOJ1799: [Ahoi2009]self 同类分布
    Oracle PL/SQL编程基础
    Oracle高级查询,事物,过程及函数
    缓存技术
    图形化报表
    网站配置与部署
    Oracle 空间管理
    Oracle 10g体系结构及安全管理
    ORACLE 数据库概述
    jQuery中的Ajax应用
  • 原文地址:https://www.cnblogs.com/tc310/p/5200109.html
Copyright © 2011-2022 走看看