title: how to call WINAPI DsRoleGetPrimaryDomainInformation in delphi?
body: <p>I am calling Windows API DsRoleGetPrimaryDomainInformation like shown in below code block. I want to get the Domain forest name and Domain DNS name. When I do <code>ShowMessage</code> for domain DNS name, it is just displaying "????" and for domain forest name it is displaying EmptyString. </p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls;
  
  type
    TForm1 = class(TForm)
      Button1: TButton;
      procedure Button1Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  
      DSROLE_PRIMARY_DOMAIN_INFO_LEVEL = (
      DsRolePrimaryDomainInfoBasic,
      DsRoleUpgradeStatus,
      DsRoleOperationState);
  
    DSROLE_MACHINE_ROLE = (
      DsRole_RoleStandaloneWorkstation,
     DsRole_RoleMemberWorkstation,
    DsRole_RoleStandaloneServer,
    DsRole_RoleMemberServer,
    DsRole_RoleBackupDomainController,
    DsRole_RolePrimaryDomainController);
  
     PDSROLE_PRIMARY_DOMAIN_INFO_BASIC = ^DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
    DSROLE_PRIMARY_DOMAIN_INFO_BASIC = record
      MachineRole: DSROLE_MACHINE_ROLE;
      Flags: ULONG; 
      DomainNameFlat: LPWSTR;
      DomainNameDns: LPWSTR;
      DomainForestName: LPWSTR;
      DomainGuid: TGUID;
    end;
  
    function DsRoleGetPrimaryDomainInformation(lpServer: LPCWSTR;
    InfoLevel: DSROLE_PRIMARY_DOMAIN_INFO_LEVEL; var Buffer: DSROLE_PRIMARY_DOMAIN_INFO_BASIC): DWORD; stdcall; external 'netapi32.dll';
  
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.DFM}
  
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
    pBuffer : DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
  begin
    if not DsRoleGetPrimaryDomainInformation(nil,DsRolePrimaryDomainInfoBasic,pBuffer) = ERROR_SUCCESS then
    begin
      ShowMessage('Something is wrong!');
      exit;
    end;
    ShowMessage(pBuffer.DomainNameDns );
    ShowMessage(pBuffer.DomainForestName);
  end;
  
  end.
  </code></pre>