2014-04-28 4 views
4

이전 프로그램을 패치하기 위해 설치 파일을 만들려고합니다. 설치 프로그램은 이전 프로그램이 설치되어 있는지 여부를 확인할 수 있어야합니다.레지스트리 키가 존재하는지 확인하고 설정을 끝내려면 어떻게합니까?

이 내 사용할 수없는 코드

[Code] 
function GetHKLM() : Integer; 

begin 
if IsWin64 then 
    begin 
    Result := HKLM64; 
    end 
    else 
    begin 
    Result := HKEY_LOCAL_MACHINE; 
    end; 
end; 

function InitializeSetup(): Boolean; 
var 
    V: string; 
begin 
    if RegKeyExists(GetHKLM(), 'SOFTWARE\ABC\Option\Settings') 
    then 
    MsgBox('please install ABC first!!',mbError,MB_OK); 
end; 

내 조건이 RegKeyExists

  • 에 대한 이전 프로그램이 설치되어 있지 않은 경우에

    • 이 창을 확인 32 비트 또는 64 비트 있어야합니다, 쇼 오류 메시지를 표시하고 설치 프로그램을 종료하십시오.

    코드를 수정하는 방법?
    미리 감사드립니다.

    ** 수정 프로그램 Wow6432Node에 대한 업데이트 문제. regedit를 경로를 볼 때 당신은 그 어느 때보 다 다른 Wow6432Node 어디를 사용해서는 안 - 내 코드

    [Code] 
    function InitializeSetup: Boolean; 
    begin 
        // allow the setup to continue initially 
        Result := True; 
        // if the registry key based on current OS bitness doesn't exist, then... 
    if IsWin64 then 
    begin 
    if not RegKeyExists(HKLM, 'SOFTWARE\Wow6432Node\ABC\Option\Settings') then 
        begin 
        // return False to prevent installation to continue 
        Result := False; 
        // and display a message box 
        MsgBox('please install ABC first!!', mbError, MB_OK); 
        end 
    
        else 
        if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings' then 
        begin 
        // return False to prevent installation to continue 
        Result := False; 
        // and display a message box 
        MsgBox('please install ABC first!!', mbError, MB_OK); 
        end 
        end; 
    end; 
    
  • 답변

    3

    질문에 업데이트 된 코드가 잘못을 수정하려고합니다.

    설명 된 동작에서 실제로 32 비트 응용 프로그램을 찾고 있습니다. 이 경우 Windows가 32 비트인지 64 비트인지에 관계없이 동일한 코드를 사용할 수 있습니다. 당신은 원래의 질문을 지나치게 생각했습니다. 여기

    가 업데이트 된 질문에서 수정 된 코드입니다 :

    [Code] 
    function InitializeSetup: Boolean; 
    begin 
        // allow the setup to continue initially 
        Result := True; 
        if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings') then 
        begin 
        // return False to prevent installation to continue 
        Result := False; 
        // and display a message box 
        MsgBox('please install ABC first!!', mbError, MB_OK); 
        end; 
    end; 
    
    +1

    내가 아마 당신이 64 비트 응용 프로그램을 직접 설치하는 매우 드문 경우에 그것을 추가해야합니다, 당신은 대신'HKLM32'를 사용해야 할 수 있습니다 위의 'HKLM'입니다. 하지만 그렇지 않으면 64 비트에 대해 걱정할 필요가 없습니다. – Miral

    +0

    적어도 ")"코드에서 누락 된 것 같습니다. – amalgamate

    +0

    @amalgamate 고정. – Miral