Q
qwert8008
Unregistered / Unconfirmed
GUEST, unregistred user!
前一段代码里没有 Reg.CloseKey;后一段代码里为什么有 Reg.CloseKey;能不能解释一下function TForm1.readRege(strKey: string): integer;var reg: TRegistry;begin reg := TRegistry.Create; try reg.RootKey := HKEY_LOCAL_MACHINE; if reg.OpenKey('SOFTWARE/Microsoft/Internet Explorer/ActiveX Compatibility/{'+strKey+'}', false) then result := reg.ReadInteger('Compatibility Flags') else result := 0; finally reg.Free; end;end;procedure TForm1.writeRege(strKey: string; intValue: integer);var reg: TRegistry;begin reg := TRegistry.Create; try reg.RootKey := HKEY_LOCAL_MACHINE; if reg.OpenKey('SOFTWARE/Microsoft/Internet Explorer/ActiveX Compatibility/{'+strKey+'}', true) then begin Reg.WriteInteger('Compatibility Flags',intValue); Reg.CloseKey; end; finally reg.Free; end;end;