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

📄 regvar.pas

📁 注册表可视化读取DELPHI控件
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit RegVar;
{ RegVar Compents can read many RegFoield values;
    Hegai qing 2000.1.20 Sapoe
    web:http://www.q311.cn
注册表可视化读取控件,直接设计时设定各键值
 }

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,Registry,StdCtrls,ExtCtrls,ShellApi,
  comctrls,imgList,Variants;

type
	TRegVar = class;
	TRegistryKeys = class;
      	TRegFields = class;

	{Each Single Key Item at the Collection}
	TRegistryKey = class (TCollectionItem)
	private
		{ Private declarations }
		V_RegistryKey : string;
		V_CreateKey: boolean;
		procedure PSetV_RegistryKey(const Value: string);
		procedure PSetV_CreateKey(const Value: boolean);
	protected
		{ Protected declarations }
		procedure DefineProperties(Filer: TFiler); override;
		function  GetDisplayName: string; override;
	public
		{ Public declarations }
		constructor Create(Collection: TCollection); override;
		destructor Destroy; override;
		procedure Assign(Source: TPersistent); override;
	published
		{ Published declarations }
		property RegistryKey : string read V_RegistryKey write PSetV_RegistryKey;
		property CreateKey: boolean read V_CreateKey write PSetV_CreateKey;
	end;

	{The Collection that group the individual keys}
	TRegistryKeys = class (TCollection)
	private
		{ Private declarations }
		V_Owner : TRegVar;
		function GetItem(Index: Integer): TRegistryKey;
		procedure SetItem(Index: Integer; Value: TRegistryKey);

	protected
		{ Protected declarations }
		function GetOwner: TPersistent; override;
		procedure Update(Item: TCollectionItem); override;

	public
		{ Public declarations }
		constructor Create(AOwner: TRegVar);
		function Add : TRegistryKey;
		property RegVar: TRegVar read V_Owner;
		property Items[Index: Integer]: TRegistryKey read GetItem write SetItem; default;
	published
		{ Published declarations }
	end;
        //return Value
	{Sets of several values of the object}
	TRootRegistryKey = (rgk_HKEY_CLASSES_ROOT,rgk_HKEY_CURRENT_USER,rgk_HKEY_LOCAL_MACHINE,rgk_HKEY_CURRENT_CONFIG);
	TVariableType = (rvt_Bool,rvt_Currency,rvt_Date,rvt_DateTime,rvt_Time,rvt_Float,rvt_Integer,rvt_String);
	TARERegistryErrorType = (AR_ErrorNone,ERR_Read_KeyNotFound,ERR_Read_ValueNotFound,ERR_Write_KeyNotFound,ERR_Write_Value,ERR_Delete_KeyNotFound,ERR_Delete_ValueNotFound);
	TARERegistryErrorNotify = procedure (Sender: TObject; ErrorType: TARERegistryErrorType; Param: string) of object;

// my   classs
        TRegField = class (TCollectionItem)
	private
		{ Private declarations }
                V_RegField : string;
       		V_VarType: TVariableType;
                V_RegValue:Variant;

                procedure PSetV_RegField(const Value: string);
       		procedure PSetV_VarType(const Value: TVariableType);
//                procedure PSetV_RegValue(const Value: Variant);
               // Function  PGetV_RegValue(DefaultRead: Variant):Variant;
	protected
		{ Protected declarations }
		procedure DefineProperties(Filer: TFiler); override;
		function  GetDisplayName: string; override;
	public
		{ Public declarations }
		constructor Create(Collection: TCollection); override;
		destructor Destroy; override;
		procedure Assign(Source: TPersistent); override;
	published
		{ Published declarations }
                property RegField : string read V_RegField write PSetV_RegField;

       		property VarType: TVariableType read V_VarType write PSetV_VarType;
                property RegValue: Variant read V_RegValue write V_RegValue;
	end;

	{The Collection that group the individual Fields}
        //add new function
	TRegFields = class (TCollection)
	private
		{ Private declarations }
		V_Owner : TRegVar;
		function GetItem(Index: Integer): TRegField;
		procedure SetItem(Index: Integer; Value: TRegField);
                function GetRegValue(aField:String):Variant;
                Procedure SetRegValue(aField:String;Value:Variant);
	protected
		{ Protected declarations }
		function GetOwner: TPersistent; override;
		procedure Update(Item: TCollectionItem); override;

	public
		{ Public declarations }
		constructor Create(AOwner: TRegVar);
		function Add : TRegField;
              	property RegVar: TRegVar read V_Owner;
		property Items[Index: Integer]: TRegField read GetItem write SetItem; default;
                Property RegValue[aField:String]:Variant read GetRegValue write SetRegValue;
	published
		{ Published declarations }
	end;

	TRegVar  = class(TComponent)
	private
		{ Private declarations }
		V_RootRegistryKey : TRootRegistryKey;
		V_RegistryKeys: TRegistryKeys;
		V_WriteOnDef : boolean;
		V_ErrorNotify: TAREregistryErrorNotify;

        V_RegFields: TRegFields;
        V_ComputerName:string;

		procedure PSetV_RootRegistryKey(const Value: TRootRegistryKey);
		procedure PSetV_RegistryKeys(const Value: TRegistryKeys);
		procedure PSetV_WriteOnDef(const Value: boolean);
	//	procedure DeleteKeyAtRegistry(Index: integer);
		function V_KeyCount: integer;

		procedure PSetV_RegFields(const Value: TRegFields);
	protected
		{ Protected declarations }
		procedure Loaded; override;
	public
		{ Public declarations }
        ConnectError:Boolean;
		constructor Create(AOwner : TComponent);override;
		destructor Destroy; override;
     //		procedure DeleteRegField(aField:TRegField);
		function ExistVariable(aField:TRegField):boolean;


        procedure ReadFrom;
        procedure WriteTo;
        procedure WriteOne(Value:TRegField);

	published
		{ Published declarations }
		{Properties}
		property RootKey : TRootRegistryKey read V_RootREgistryKey write PSetV_RootRegistryKey;
		property Keys: TRegistryKeys read V_RegistryKeys write PSetV_RegistryKeys;
		property WriteOnDef: boolean read V_WriteOnDef write PSetV_WriteOnDef;
		property KeyCount: integer read V_KeyCount;

		property Fields: TRegFields read V_RegFields write PSetV_RegFields;
        property ComputerName:string read V_computername write v_computerName;
		{Events}
		property OnError: TAREregistryErrorNotify read V_ErrorNotify write V_ErrorNotify;



	end;

procedure Register;

implementation

const

(* Image Information *)
// Height	: 016
// Width 	: 016

	V_FolderHeight			= 016;
	V_FolderWidth			= 016;
{	V_Folder: array[1..256] of DWord = (
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00FFFFFF,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00848484,$00C6C6C6,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00848484,$00C6C6C6,$0000FFFF,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00848484,$0000FFFF,$00C6C6C6,$00FFFFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00848484,$00C6C6C6,$0000FFFF,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00848484,$0000FFFF,$00C6C6C6,$00FFFFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00848484,$00C6C6C6,$0000FFFF,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00848484,$00C6C6C6,$00FFFFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00FFFFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00FFFFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00FFFFFF,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00C6C6C6,$0000FFFF,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00848484,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00FFFFFF,$00FFFFFF,
												   $00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF,$00FFFFFF);
}
(* Image Information *)
// Height	: 016

⌨️ 快捷键说明

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