Inno Setup检查计算机是否已加入域

时间:2014-08-26 17:00:11

标签: inno-setup

有没有办法检查您正在安装的计算机是加入域还是工作组?

我发现这篇文章是关于如何在Delphi中执行此操作,但我无法在Inno Setup中使用它。任何人都可以协助吗?这甚至可能吗?

http://delphi.about.com/od/delphitips2009/qt/computer-in-a-domain.htm

1 个答案:

答案 0 :(得分:2)

我会这样翻译(并缩短):

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
const
  NERR_BASE = 2100;
  NERR_SetupNotJoined = NERR_BASE + 592;

type
  NET_API_STATUS = DWORD;

function NetRenameMachineInDomain(lpServer: WideString;
  lpNewMachineName: WideString; lpAccount: WideString;
  lpPassword: WideString; fRenameOptions: DWORD): NET_API_STATUS;
  external 'NetRenameMachineInDomain@netapi32.dll stdcall';

function IsInDomain: Boolean;
begin 
  Result := NetRenameMachineInDomain('', '', '', '', 0) <> NERR_SetupNotJoined;
end;

procedure InitializeWizard;
begin
  if IsInDomain then
    MsgBox('Is in domain.', mbInformation, MB_OK)
  else
    MsgBox('Is not in domain.', mbInformation, MB_OK);
end;