Excerpt |
---|
TRegistry enables you to read registry entry. |
Below code shows the sample to read registry entry.
Code Block |
---|
uses System.Win.Registry; . . . procedure TMainFrm.LoadConfiguration; var myReg: TRegistry; begin myReg := TRegistry.Create( KEY_READ); try myReg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE if myReg.OpenKey('Software\Junpa Encoder\', true) then try edTargetDir.Text := myReg.ReadString('TargetDir'); cbMediaType.ItemIndex := myReg.ReadInteger('MediaType'); cbVideoResolution.ItemIndex := myReg.ReadInteger('VideoResolution'); cbVideoCodec.ItemIndex := myReg.ReadInteger('VideoCodec'); cbAudioCodec.ItemIndex := myReg.ReadInteger('AudioCodec'); cbSplitMedia.ItemIndex := myReg.ReadInteger('SplitMedia'); cbDeleteAfterConversion.Checked := myReg.ReadBool('DeleteAfterConversion'); cbAutoChangeDir.Checked := myReg.ReadBool('AutoChangeDir'); finally myReg.CloseKey; end; finally myReg.Free; end; Close; end; procedure TMainFrm.SaveConfiguration; var myReg: TRegistry; begin myReg := TRegistry.Create( KEY_SET_VALUE); try myReg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE if myReg.OpenKey('Software\Junpa Encoder\', true) then try myReg.WriteString('TargetDir', edTargetDir.Text); myReg.WriteInteger('MediaType', cbMediaType.ItemIndex); myReg.WriteInteger('VideoResolution', cbVideoResolution.ItemIndex); myReg.WriteInteger('VideoCodec', cbVideoCodec.ItemIndex); myReg.WriteInteger('AudioCodec', cbAudioCodec.ItemIndex); myReg.WriteInteger('SplitMedia', cbSplitMedia.ItemIndex); myReg.WriteBool('DeleteAfterConversion', cbDeleteAfterConversion.Checked); myReg.WriteBool('AutoChangeDir', cbAutoChangeDir.Checked); finally myReg.CloseKey; end; finally myReg.Free; end; Close; end; |