var
tmp:string;
tmp:string;
const
REG_INSTALL_PATH_ITEM='InstallPath';
REG_INSTALL_KEY='SOFTWARE\Blizzard Entertainment\World of Warcraft';
REG_INSTALL_PATH_ITEM='InstallPath';
REG_INSTALL_KEY='SOFTWARE\Blizzard Entertainment\World of Warcraft';
function readreg(sKey:string;var pBuffer:string;dwBufSize:dword;key:hkey;sSubKey:string;ulType:dword):boolean;
var
sTemp:pchar;
hSubKey: hkey;
Datatype:dword;
begin
result:=false;
if RegOpenKeyEx(key,pchar(sSubkey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
exit;
end;
try
getmem(sTemp,dwBufSize);
if (RegQueryValueEx(hSubKey,pchar(sKey),nil,@Datatype,pbyte(sTemp),@dwBufSize)=0)and(DataType = ulType) then
begin
pBuffer:=sTemp;
result:=true;
end;
finally
RegCloseKey(hSubKey);
freemem(sTemp);
end;
end;
var
sTemp:pchar;
hSubKey: hkey;
Datatype:dword;
begin
result:=false;
if RegOpenKeyEx(key,pchar(sSubkey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
exit;
end;
try
getmem(sTemp,dwBufSize);
if (RegQueryValueEx(hSubKey,pchar(sKey),nil,@Datatype,pbyte(sTemp),@dwBufSize)=0)and(DataType = ulType) then
begin
pBuffer:=sTemp;
result:=true;
end;
finally
RegCloseKey(hSubKey);
freemem(sTemp);
end;
end;
begin
ReadReg( REG_INSTALL_PATH_ITEM,
Tmp,
MAX_PATH,
HKEY_LOCAL_MACHINE,
REG_INSTALL_KEY, REG_SZ
);
showmessage(tmp);
end.
===========================================
function savereg(sKey:string;pBuffer:string;dwBufSize:dword;key:hkey;sSubKey:string;ulType:dword):boolean;
var
hSubKey: hkey;
begin
result:=false;
if RegOpenKeyEx(key,pchar(sSubKey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
if RegCreateKey(key,pchar(sSubKey),hSubKey)<>0 then
exit;
end;
try
if RegSetValueEx(hSubKey,pchar(sKey),0,ulType,pbyte(pchar(pBuffer)),dwBufSize)=0 then
begin
result:=true;
end;
finally
RegCloseKey(hSubKey);
end;
end;
function deletereg(key:hkey;sSubKey:string;sItem:string):boolean;
var
hSubKey:hkey;
begin
result:=false;
if (key=0)or(sSubKey='') then
exit;
if sItem='' then
begin
if RegDeleteKey(key,pchar(sSubKey))=0 then
begin
result:=true;
exit;
end
else
exit;
end;
if RegOpenKeyEx(key,pchar(sSubkey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
exit;
end;
try
if RegDeleteValue(hSubKey, pchar(sItem))=0 then
result:=true;
finally
RegCloseKey(hSubKey);
end;
end;
var
hSubKey: hkey;
begin
result:=false;
if RegOpenKeyEx(key,pchar(sSubKey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
if RegCreateKey(key,pchar(sSubKey),hSubKey)<>0 then
exit;
end;
try
if RegSetValueEx(hSubKey,pchar(sKey),0,ulType,pbyte(pchar(pBuffer)),dwBufSize)=0 then
begin
result:=true;
end;
finally
RegCloseKey(hSubKey);
end;
end;
function deletereg(key:hkey;sSubKey:string;sItem:string):boolean;
var
hSubKey:hkey;
begin
result:=false;
if (key=0)or(sSubKey='') then
exit;
if sItem='' then
begin
if RegDeleteKey(key,pchar(sSubKey))=0 then
begin
result:=true;
exit;
end
else
exit;
end;
if RegOpenKeyEx(key,pchar(sSubkey),0,KEY_ALL_ACCESS,hSubKey)<>0 then
begin
exit;
end;
try
if RegDeleteValue(hSubKey, pchar(sItem))=0 then
result:=true;
finally
RegCloseKey(hSubKey);
end;
end;