⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 n5u_reg.~pas

📁 右键菜单实现文件加密
💻 ~PAS
字号:
unit N5U_Reg;

interface

uses
  Windows, Registry, SysUtils;

type


  TReg = class (TObject)
  public
    class function GetRegString(RootKey: HKEY; Section, Key, DefaultValue:
            string): string;
    class function SetRegString(Rootkey: HKEY; Section, Key, Value: string):
            Boolean;
    class function LoadFromReg(const KeyName: string): string;
    class procedure SaveToReg(const KeyName, KeyValue: string);

  end;




implementation

const
  DefConnStr = '';
  MyRegSection = '\Software\Thunis\ThAMS\EncrypFile';

{ TReg }
{
************************************* TReg *************************************
}


class function TReg.GetRegString(RootKey: HKEY; Section, Key, DefaultValue: 
        string): string;
var
  MyReg: TRegistry;
begin
  Result := DefaultValue;
  
  MyReg := TRegistry.Create;
  if MyReg <> nil then
  begin
    MyReg.RootKey := RootKey;
    if MyReg.OpenKeyReadOnly(Section) then
    begin
      Result := MyReg.ReadString(Key);
      if Result = '' then Result := DefaultValue;
      MyReg.CloseKey;
    end;
    MyReg.Free;
  end;
end;

class function TReg.LoadFromReg(const KeyName: string): string;
begin
  Result:=Getregstring(HKEY_LOCAL_MACHINE,MyRegSection,KeyName,'');
  
end;

class procedure TReg.SaveToReg(const KeyName, KeyValue: string);
begin
  Setregstring(HKEY_LOCAL_MACHINE,MyRegSection,KeyName,KeyValue);
end;

class function TReg.SetRegString(Rootkey: HKEY; Section, Key, Value: string): 
        Boolean;
var
  MyReg: TRegistry;
begin
  result := false;
  MyReg := TRegistry.Create;
  if MyReg <> nil then
  begin
    MyReg.RootKey := RootKey;
    if myreg.OpenKey(Section, true) then
    begin
      myreg.WriteString(key, value);
      result := true;
    end;
  end;
  myreg.CloseKey;
  myreg.Free;
end;






end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -