给个例子给你,呵呵
procedure TMainForm.FormCreate(Sender: TObject);
var Registry: TRegistry;
begin
Registry:=TRegistry.Create;
Registry.RootKey:=HKEY_LOCAL_MACHINE;
Registry.OpenKey('\SoftWare\sgliuxiu工作室\现金收费\',True);
SysDba:=Registry.ReadString('SysDba');
SysPassWord:=Registry.ReadString('SysPassWord');
BranchName:=Registry.ReadString('BranchNo');
Programmer:=Registry.ReadString('Programmer');
TerminalNo:=Registry.ReadString('TerminalNo');
Provider1:=Registry.ReadString('Provider');
IpAdress:=Registry.ReadString('IPAddress');
RemoteServer:=Registry.ReadString('Remote Server');
DefaultDatabase1:=Registry.ReadString('DefaultDatabase');
Registry.CloseKey;
Registry.Free;
end;
var Registry: TRegistry; registry是自己定义的变量名啊.
delphi里面的帮助文件,你看看.
If you are writing a Windows-only application and are comfortable with the structure of the system Registry, you can use TRegistry. Unlike TRegistryIniFile, which uses the same properties and methods of other ini file components, the properties and methods of TRegistry correspond more directly to the structure of the system Registry. For example, TRegistry lets you specify both the root key and subkey, while TRegistryIniFile assumes HKEY_CURRENT_USER as a root key. In addition to methods for opening, closing, saving, moving, copying, and deleting keys, TRegistry lets you specify the access level you want to use.
Note
TRegistry is not available for cross-platform programming.
The following example retrieves a value from a registry entry:
function GetRegistryValue(KeyName: string): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ);
try
Registry.RootKey = HKEY_LOCAL_MACHINE;
// False because we do not want to create it if it doesn't exist
Registry.OpenKey(KeyName, False);
Result := Registry.ReadString('VALUE1');
finally
Registry.Free;
end;
end;