打印本文 打印本文 关闭窗口 关闭窗口
选择一个网路邻居
作者:武汉SEO闵涛  文章来源:敏韬网  点击数890  更新时间:2009/4/23 18:30:46  文章录入:mintao  责任编辑:mintao

=================   选择一个网路邻居   =====================
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;

打印本文 打印本文 关闭窗口 关闭窗口