Mega Code Archive

 
Categories / Delphi / System
 

Getting the data type of a registry value (for beginners)

Title: Getting the data type of a registry value (for beginners) Question: How you can get the data type of a registry value Answer: Declare the unit Registry in your USES clause. // return a the string data type of a registry value function GetRegDataType(const strRegPath, strRegValue: string): string; var s: string; objRegistry: TRegistry; begin try // creates the registru manager object objRegistry := TRegistry.Create; objRegistry.RootKey := HKEY_LOCAL_MACHINE; // opens the specified key if exists if objRegistry.OpenKey(strRegPath, false) then begin case objRegistry.GetDataType(strRegValue) of rdUnknown: s := 'Unknown'; rdString: s := 'String'; rdExpandString: s := 'ExpandString'; rdInteger: s := 'Inteiro'; rdBinary: s := 'Binrio'; end; end else s := '(Can't get data type)'; finally // destroys the registry manager object objRegistry.Free; end; // set the return result := s; end;