1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| function ReadString(RootKey: HKEY; RegKey, RegVal: string) : string; var SubKey : array [0..80] of char; rgHandle : HKEY; lpType, cbData : DWORD; begin Result := ''; fillchar(SubKey, sizeof(SubKey), 0);
lstrcpy(SubKey, pchar(RegKey));
rgHandle := 0; if(RegOpenKeyEx(RootKey,SubKey,0,KEY_QUERY_VALUE,rgHandle) = ERROR_SUCCESS) then try lpType := REG_NONE; cbData := 0;
if(RegQueryValueEx(rgHandle,pchar(RegVal),nil,@lpType,nil,@cbData) = ERROR_SUCCESS) and ((lpType = REG_SZ) or (lpType = REG_EXPAND_SZ)) and (cbData > 1) then begin SetLength(Result, cbData); if(RegQueryValueEx(rgHandle,pchar(RegVal),nil, nil,@Result[1],@cbData) = ERROR_SUCCESS) then SetLength(Result, cbData - 1) else Result := ''; end; finally RegCloseKey(rgHandle); end; end; |