首页  编辑  

显示“选择域”对话框

Tags: /超级猛料/Network.网络通讯/共享和用户、域/   Date Created:

显示"选择域"对话框?

show the 'Choose Domain' dialog?

{

 If you are developing network software for Windows NT,

 you usually need to ask the user to select a computer or domain

 he wants to connect/login.

}

const

 FOCUSDLG_DOMAINS_ONLY = 1 ;

 FOCUSDLG_SERVERS_ONLY = 2 ;

 FOCUSDLG_SERVERS_DOMAINS = 3 ;

 FOCUSDLG_BROWSE_LOGON_DOMAIN = $00010000 ;

 FOCUSDLG_BROWSE_WKSTA_DOMAIN = $00020000 ;

 FOCUSDLG_BROWSE_OTHER_DOMAINS = $00040000 ;

 FOCUSDLG_BROWSE_TRUSTING_DOMAINS = $00080000 ;

 FOCUSDLG_BROWSE_WORKGROUP_DOMAINS = $00100000 ;

 FOCUSDLG_BROWSE_ALL_DOMAINS = FOCUSDLG_BROWSE_LOGON_DOMAIN or

   FOCUSDLG_BROWSE_WKSTA_DOMAIN or FOCUSDLG_BROWSE_OTHER_DOMAINS or

   FOCUSDLG_BROWSE_TRUSTING_DOMAINS or FOCUSDLG_BROWSE_WORKGROUP_DOMAINS ;

function SystemFocusDialog ( hwndOwner : HWND ; dwSelectionFlag : UINT ;

 wszName : PWideChar ; dwBufSize : DWORD ; var bOKPressed : Boolean ;

 wszHelpFile : PWideChar ; dwContextHelpId : DWORD ): DWORD ; stdcall ;

  external 'ntlanman.dll' Name 'I_SystemFocusDialog' ;

function ComputerBrowser ( hWndParent : HWND ; wCompName : PWideChar ;

 dwBufLen : DWORD ): Boolean ;

var

 dwError           : DWORD ;

begin

 Result := False ;

 dwError := SystemFocusDialog ( hWndParent , FOCUSDLG_SERVERS_DOMAINS or

   FOCUSDLG_BROWSE_ALL_DOMAINS ,

   wCompName , dwBufLen , Result , nil , 0 );

  if dwError <> NO_ERROR then Exit ;

end ;

procedure TForm1 . Button1Click ( Sender : TObject );

var

 wCompName         : array [ 0 .. MAX_COMPUTERNAME_LENGTH + 1 ] of WideChar ;

begin

  if ComputerBrowser ( 0 , wCompName , MAX_COMPUTERNAME_LENGTH + 1 ) then

   ShowMessage ( wCompName )

  else

   ShowMessage ( 'no computer selected' );

end ;