www.pudn.com > 自动计划(autoplan)源代码___强烈推荐 .rar > Unt_Confif.pas


unit Unt_Confif; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs,shellapi, ComCtrls, StdCtrls, ExtCtrls, Spin, Buttons,Registry,unt_fun, 
  MMSystem; 
 
type 
  TFrm_Config = class(TForm) 
    PageControl1: TPageControl; 
    TabSheet1: TTabSheet; 
    Image1: TImage; 
    GroupBox1: TGroupBox; 
    Label1: TLabel; 
    Cbo_GJFS: TComboBox; 
    GroupBox2: TGroupBox; 
    Label2: TLabel; 
    SpinEdit1: TSpinEdit; 
    Label3: TLabel; 
    BitBtn1: TBitBtn; 
    BitBtn2: TBitBtn; 
    GroupBox8: TGroupBox; 
    CB_Volume: TCheckBox; 
    Edit1: TEdit; 
    BitBtn4: TBitBtn; 
    OpenDialog1: TOpenDialog; 
    GroupBox7: TGroupBox; 
    CB_zdsj: TCheckBox; 
    Cb_zdxz: TCheckBox; 
    GroupBox6: TGroupBox; 
    CB_xsjd: TCheckBox; 
    CBO_wz: TComboBox; 
    procedure SpinEdit1Change(Sender: TObject); 
    procedure BitBtn4Click(Sender: TObject); 
    procedure BitBtn3Click(Sender: TObject); 
    procedure CB_VolumeClick(Sender: TObject); 
    procedure Cbo_GJFSChange(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure CB_zdsjClick(Sender: TObject); 
    procedure Cb_zdxzClick(Sender: TObject); 
    procedure CB_xsjdClick(Sender: TObject); 
    procedure BitBtn1Click(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Frm_Config: TFrm_Config; 
 
implementation 
 
{$R *.dfm} 
 
procedure TFrm_Config.SpinEdit1Change(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('TimeLeave',True); 
      Reg.writeinteger('Time',SpinEdit1.Value); 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.BitBtn4Click(Sender: TObject); 
begin 
  sndPlaySound(pchar(edit1.text),SND_SYNC); 
end; 
 
procedure TFrm_Config.BitBtn3Click(Sender: TObject); 
begin 
  OpenDialog1.Execute; 
  Edit1.Text := OpenDialog1.FileName; 
end; 
 
procedure TFrm_Config.CB_VolumeClick(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('volume',True); 
      if CB_Volume.Checked then 
      begin 
        if Visible then 
        begin 
          OpenDialog1.Filter := '声音文件(*.wav)|*.wav;|所有文件|*.*' ; 
          OpenDialog1.Title := '添加声音'; 
          OpenDialog1.Execute; 
        end; 
        if OpenDialog1.FileName <> '' then 
        begin 
          Reg.WriteBool('flag',True) ; 
          Edit1.Text := OpenDialog1.FileName; 
          reg.WriteString('file',OpenDialog1.FileName); 
        end; 
      end 
      else 
        Reg.WriteBool('flag',false); 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.Cbo_GJFSChange(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('CloseType',True); 
      Reg.writeinteger('Type',Cbo_GJFS.ItemIndex); 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.FormCreate(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
try 
  //******************************************关机方式 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('CloseType',True); 
      Cbo_GJFS.ItemIndex := Reg.ReadInteger('Type'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************延长时间 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('TimeLeave',True); 
      SpinEdit1.Value := Reg.ReadInteger('Time'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************声音提醒 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('volume',True); 
      CB_Volume.Checked := Reg.ReadBool('flag'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************声音文件 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('volume',false); 
      Edit1.Text := Reg.Readstring('file'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************新版本自动升级 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('autoupdate',true); 
      CB_zdsj.Checked := Reg.ReadBool('flag'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************新插件自动下载 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('PlugDownload',false); 
      Cb_zdxz.Checked := Reg.ReadBool('flag'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************关机显示进度 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('showProgress',false); 
      CB_xsjd.Checked := Reg.ReadBool('flag'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
  //******************************************进度显示位置 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('showProgress',false); 
      CBO_wz.ItemIndex := Reg.ReadInteger('Layout'); 
      Reg.CloseKey; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
except 
end; 
end; 
 
procedure TFrm_Config.CB_zdsjClick(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('autoupdate',True); 
      Reg.WriteBool('flag', CB_zdsj.Checked); 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.Cb_zdxzClick(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      Reg.OpenKey('PlugDownload',True); 
      Reg.WriteBool('flag',Cb_zdxz.Checked); 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.CB_xsjdClick(Sender: TObject); 
var 
  Reg: TRegistry; 
begin 
  Reg := TRegistry.Create; 
  try 
    Reg.RootKey := HKEY_LOCAL_MACHINE; 
    if Reg.OpenKey('\Software\AutoPlan', True) then 
    begin 
      if Visible then 
      begin 
        Reg.OpenKey('showProgress',True); 
        Reg.WriteBool('flag',CB_xsjd.Checked); 
        reg.WriteInteger('Layout',CBO_wz.ItemIndex); 
      end; 
    end; 
  finally 
    Reg.CloseKey; 
    Reg.Free ; 
  end; 
end; 
 
procedure TFrm_Config.BitBtn1Click(Sender: TObject); 
begin 
  close; 
end; 
 
end.