DelphiFAQ Home Search:

Display the 'Choose Computer' dialog in a Delphi application

 

comments3 comments. Current rating: 3 stars (1 votes). Leave comments and/ or rate it.

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 }

Content-type: text/html

Comments:

2012-06-05, 21:36:03
anonymous from China  
<strong> http://www.coachout..strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong> http://www.myloveco..strong> <a href=' http://www.myloveco..g>Coach Outlet Online</strong></a><br />
<strong> http://www.buyincoa..strong> <a href=' http://www.buyincoa..g>Coach Outlet</strong></a><br />
<strong> http://www.cheapcoa..strong> <a href=' http://www.cheapcoa..g>Cheap Coach Handbags</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory Outlet</strong></a><br />
<strong> http://www.buycoach..strong> <a href=' http://www.buycoach..g>Coach Outlet Online</strong></a><br />
<strong>www.coachoutletonfactory.net</strong> <a href=' http://www.coachout..g>Coach Factory Outlet</strong></a><br />
<strong>www.coachoutletonline4you.us</strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong>coachfactoryoutletq.net</strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong>gotocoachoutlets.net</strong> <a href=' http://www.gotocoac..g>Coach Outlet Online</strong></a><br />
2012-09-27, 03:30:43
 
rating
nqiyyn <a href=' http://ukpaydayloansfh.co.uk/ '>payday loans</a> :-O <a href=' http://uspaydayloansfh.com/ '>pay day loan</a> IeDbl <a href=' http://canadapayday..oansta.ca/ '>pay day loan</a> eqwjg
2015-01-30, 01:20:53
anonymous  
Needed to put you one little bit of rearmk to say thank you yet again for all the precious opinions you have contributed in this article. This is certainly surprisingly generous of you to supply unhampered all most people might have sold for an electronic book to help make some dough on their own, particularly given that you might well have done it in case you desired. These ideas as well acted as the great way to recognize that other people online have the same zeal just like my personal own to figure out more regarding this problem. I'm sure there are numerous more pleasurable situations in the future for people who go through your website.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: