您的位置:首页 > 其它

LAMP安装时出现的一些错误及解决

2009-09-09 15:24 543 查看
var
tmp:string;
 
const
  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;
 

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐