[TRUCO DELPHI] Seleccionar Ordenador.
delphi
Uses ActiveX, ShlObj, Windows; function SelectComputer(Const Caption: String; out Computer: String): Boolean; Var BrowseInfo : TBrowseInfo; ShellMalloc : IMalloc; RootItemIDList: PItemIDList; ItemIDList : PItemIDList; Buffer : PChar; begin Result := False; Computer := ''; FillChar(BrowseInfo, SizeOf(BrowseInfo), 0); If (ShGetMalloc(ShellMalloc) = S_OK) And (ShellMalloc <> Nil) Then begin Buffer := ShellMalloc.Alloc(MAX_COMPUTERNAME_LENGTH + 1); try SHGetSpecialFolderLocation(0, CSIDL_NETWORK, RootItemIDList); With BrowseInfo Do begin hwndOwner := Application.Handle; pidlRoot := RootItemIDList; pszDisplayName := Buffer; lpszTitle := PChar(Caption); ulFlags := BIF_BROWSEFORCOMPUTER; end; ItemIDList := ShBrowseForFolder(BrowseInfo); Result := (ItemIDList <> Nil); If Result Then begin ShellMalloc.Free(ItemIDList); Computer := AnsiUpperCase(Buffer); end; finally ShellMalloc.Free(RootItemIDList); ShellMalloc.Free(Buffer); end; end; end;
Saludos!