您的位置:首页 > 其它

选择一个网路邻居

2004-10-09 10:18 225 查看
=================   选择一个网路邻居   =====================
function SelectComputerName(handle: hwnd; var ComputerName: string): boolean;
var
  BrowseInfo: TBrowseInfo;
  ItemIDList: PItemIDList;
  cName: array[0..MAX_PATH] of Char;
  Title: string;
  WindowList: Pointer;
begin
  if Failed(SHGetSpecialFolderLocation(Handle, CSIDL_NETWORK, ItemIDList)) then
    raise Exception.CreateRes(@SComputerNameDialogNotSupported);
  FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
  BrowseInfo.hwndOwner := Handle;
  BrowseInfo.pidlRoot := ItemIDList;
  BrowseInfo.pszDisplayName := cName;
  Title := '选择计算机名(Remote Server):';
  BrowseInfo.lpszTitle := PChar(Pointer(Title));
  BrowseInfo.ulFlags := BIF_BROWSEFORCOMPUTER;
  WindowList := DisableTaskWindows(0);
  try
    Result := SHBrowseForFolder(BrowseInfo) <> nil;
  finally
    EnableTaskWindows(WindowList);
  end;
  ComputerName := cName;
end;

procedure Tfrm_Login.bt_ComputerSetClick(Sender: TObject);
var A_Computer:string;
begin
  if SelectComputerName(handle,A_Computer) then begin
    showMessage( 'the computer's name is :'+ A_Computer ) ;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息