DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Display the 'Choose Computer' dialog in a Delphi application

Question:

How can I display the 'Choose Computer' dialog in my Delphi application?

Answer:

The "Choose Computer" dialog is provided by network services (NTLANMAN.DLL) for Windows 2k/NT/XP to display the servers and their computers. The code below follows these steps:
  1. dynamically load the DLL with LoadLibrary('NTLANMAN.DLL');
  2. bind the function with GetProcAddress()
  3. call this function (result returned in buffer of characters)
  4. free the library

You can call it as shown in the button's onClick event handler.

{------------------------------------------------------------------------
   Der "Computer auswählen" Dialog ist ein Dialog von Windows
   2k/NT/XP (NTLANMAN.DLL) mit einer ListView in dem der Server
   und die dazugehörigen Computer angezeigt werden.
 
   The "Choose Computer" dialog is provided by network services
   (NTLANMAN.DLL) for Windows 2k/NT/XP to display the servers
   and their computers.
  ------------------------------------------------------------------------}
 type
   TServerBrowseDialogA0 = function(HWND: HWND; pchBuffer: Pointer;
                                    cchBufSize: DWord) : bool;
     stdcall;
 
 {sc-----------------------------------------------------------------------
   Name:       ShowServerDialog
   Parameters:
      AHandle
 -----------------------------------------------------------------------sc}
 function ShowServerDialog(AHandle: THandle) : string;
 var
   ServerBrowseDialogA0: TServerBrowseDialogA0;
   LANMAN_DLL: DWord;
   buffer: array [0..1024] of Char;
   bLoadLib: boolean;
 begin { ShowServerDialog }
   LANMAN_DLL := GetModuleHandle('NTLANMAN.DLL');
 
   if LANMAN_DLL=0 then
   begin
     LANMAN_DLL := LoadLibrary('NTLANMAN.DLL');
 
     bLoadLib := True
   end; { LANMAN_DLL=0 }
   if LANMAN_DLL<>0 then
   begin
     @ServerBrowseDialogA0 := GetProcAddress(LANMAN_DLL, 'ServerBrowseDialogA0');
 
     ServerBrowseDialogA0(AHandle, @buffer, 1024);
 
     if buffer[0]='\' then
     begin
       Result := buffer
     end; { buffer[0]='\' }
     if bLoadLib then
       FreeLibrary(LANMAN_DLL)
   end; { LANMAN_DLL<>0 }
 end; { ShowServerDialog }
 
 
 {sc-----------------------------------------------------------------------
   Name:       TForm1.Button1Click
   Parameters:
      Sender
 -----------------------------------------------------------------------sc}
 procedure TForm1.Button1Click(Sender: TObject);
 begin { TForm1.Button1Click }
   Label1.Caption := ShowServerDialog(Form1.Handle)
 end; { TForm1.Button1Click }
 

Generated 20:02:02 on Oct 17, 2018