Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Display the 'Choose Computer' dialog in a Delphi application
This article has not been rated yet. After reading, feel free to leave comments and 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:
- dynamically load the DLL with LoadLibrary('NTLANMAN.DLL');
- bind the function with GetProcAddress()
- call this function (result returned in buffer of characters)
- free the library
You can call it as shown in the button's onClick event handler.
 | |  | |
type
TServerBrowseDialogA0 = function(HWND: HWND; pchBuffer: Pointer;
cchBufSize: DWord) : bool;
stdcall;
function ShowServerDialog(AHandle: THandle) : string;
var
ServerBrowseDialogA0: TServerBrowseDialogA0;
LANMAN_DLL: DWord;
buffer: array [0..1024] of Char;
bLoadLib: boolean;
begin
LANMAN_DLL := GetModuleHandle('NTLANMAN.DLL');
if LANMAN_DLL=0 then
begin
LANMAN_DLL := LoadLibrary('NTLANMAN.DLL');
bLoadLib := True
end;
if LANMAN_DLL<>0 then
begin
@ServerBrowseDialogA0 := GetProcAddress(LANMAN_DLL, 'ServerBrowseDialogA0');
ServerBrowseDialogA0(AHandle, @buffer, 1024);
if buffer[0]='\' then
begin
Result := buffer
end;
if bLoadLib then
FreeLibrary(LANMAN_DLL)
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := ShowServerDialog(Form1.Handle)
end;
| |  | |  |
Comments:
|