Perhatikan code berikut :
uses registry; procedure TForm1.Button1Click(Sender: TObject) ; var reg:TRegistry; begin reg:=TRegistry.Create; with reg do begin try if OpenKey('\Control Panel\desktop', False) then begin //change wallpaper and tile it reg.WriteString ('Wallpaper','c:\windows\CIRCLES.bmp') ; reg.WriteString ('TileWallpaper','1') ; //disable screen saver//('0'=disable, '1'=enable) reg.WriteString('ScreenSaveActive','0') ; //update changes immediately SystemParametersInfo (SPI_SETDESKWALLPAPER,0, nil,SPIF_SENDWININICHANGE) ; SystemParametersInfo (SPI_SETSCREENSAVEACTIVE,0, nil,SPIF_SENDWININICHANGE) ; end finally reg.Free; end; end; end;
prosedur di atas akan menyimpan data ke dalam registry.
Berikut adalah fungsi dan prosedur dari class Tregistry.
Writestring(key:string;data:string) procedure CloseKey; function CreateKey(const Key: string): Boolean; function DeleteKey(const Key: string): Boolean; function DeleteValue(const Name: string): Boolean; function GetDataInfo(const ValueName: string; var Value: TRegDataInfo): Boolean; function GetDataSize(const ValueName: string): Integer; function GetDataType(const ValueName: string): TRegDataType; function GetKeyInfo(var Value: TRegKeyInfo): Boolean; procedure GetKeyNames(Strings: TStrings); procedure GetValueNames(Strings: TStrings); function HasSubKeys: Boolean; function KeyExists(const Key: string): Boolean; function LoadKey(const Key, FileName: string): Boolean; procedure MoveKey(const OldName, NewName: string; Delete: Boolean); function OpenKey(const Key: string; CanCreate: Boolean): Boolean; function OpenKeyReadOnly(const Key: String): Boolean; function ReadCurrency(const Name: string): Currency; function ReadBinaryData(const Name: string; var Buffer; BufSize: Integer): Integer; function ReadBool(const Name: string): Boolean; function ReadDate(const Name: string): TDateTime; function ReadDateTime(const Name: string): TDateTime; function ReadFloat(const Name: string): Double; function ReadInteger(const Name: string): Integer; function ReadString(const Name: string): string; function ReadTime(const Name: string): TDateTime; function RegistryConnect(const UNCName: string): Boolean; procedure RenameValue(const OldName, NewName: string); function ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean; function RestoreKey(const Key, FileName: string): Boolean; function SaveKey(const Key, FileName: string): Boolean; function UnLoadKey(const Key: string): Boolean; function ValueExists(const Name: string): Boolean; procedure WriteCurrency(const Name: string; Value: Currency); procedure WriteBinaryData(const Name: string; var Buffer; BufSize: Integer); procedure WriteBool(const Name: string; Value: Boolean); procedure WriteDate(const Name: string; Value: TDateTime); procedure WriteDateTime(const Name: string; Value: TDateTime); procedure WriteFloat(const Name: string; Value: Double); procedure WriteInteger(const Name: string; Value: Integer); procedure WriteString(const Name, Value: string); procedure WriteExpandString(const Name, Value: string); procedure WriteTime(const Name: string; Value: TDateTime); property CurrentKey: HKEY read FCurrentKey; property CurrentPath: string read FCurrentPath; property LazyWrite: Boolean read FLazyWrite write FLazyWrite; property RootKey: HKEY read FRootKey write SetRootKey; property Access: LongWord read FAccess write FAccess;
Tidak ada komentar:
Posting Komentar