unit Emulator_Registry; interface USES xRegistry, MI1201AGM_Emulator_DLL_Headers; type tEmulatorRegistry=class(tRegistry) private function SubPath(const ASubPath:string):string; public function RootPath:string; function OpenRootRead:boolean; function OpenRootWrite:boolean; function OpenRead(const ASubPath:string):boolean; function OpenWrite(const ASubPath:string):boolean; end; function EmulatorRegistry:tEmulatorRegistry; implementation Uses Windows; function tEmulatorRegistry.SubPath(const ASubPath:string):string; begin if ASubPath[1]='\' then Result:=Copy(ASubPath,1,Length(ASubPath)) else Result:=ASubPath; end; function tEmulatorRegistry.OpenRead(const ASubPath:string):boolean; begin Result:=OpenRootRead; if Result then Result:=OpenKeyReadOnly(SubPath(ASubPath)); end; function tEmulatorRegistry.OpenWrite(const ASubPath:string):boolean; begin Result:=OpenRootWrite; if Result then Result:=OpenKey(SubPath(ASubPath),True); end; function tEmulatorRegistry.RootPath:string; begin Result:='\'+cRegistryKey; end; function tEmulatorRegistry.OpenRootRead:boolean; begin CloseKey; RootKey:=HKEY_CURRENT_USER; Result:=OpenKeyReadOnly(RootPath); end; function tEmulatorRegistry.OpenRootWrite:boolean; begin CloseKey; RootKey:=HKEY_CURRENT_USER; Access:=KEY_WRITE; Result:=OpenKey(RootPath, TRUE); end; var prRegistry:tEmulatorRegistry=NIL; Finished:boolean; function EmulatorRegistry:tEmulatorRegistry; begin if not Finished and not Assigned(prRegistry) then begin prRegistry:=tEmulatorRegistry.Create; end; Result:=prRegistry; end; initialization finalization Finished:=TRUE; prRegistry.Free; end.