怎样才能得到局域网络中的计算名?

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1149/1149863.xml?temp=.8173029
      

  2.   

    Google上找例子,太多了,
    有组件也有代码的
    太长贴不出来了,自己去找了
      

  3.   

    uses shlobjfunction PromptLookServerName(Handle:Thandle):string;
    var
      BrowseInfo: TBrowseInfo;
      ItemIDList: PItemIDList;
      ComputerName: array[0..MAX_PATH] of Char;
      Title: string;
      WindowList: Pointer;
      aResult: Boolean;
    begin
      if Failed(SHGetSpecialFolderLocation(Application.Handle,CSIDL_NETWORK, ItemIDList)) then
        exit;
      FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
      BrowseInfo.hwndOwner := Handle;
      BrowseInfo.pidlRoot :=ItemIDList;
      BrowseInfo.pszDisplayName := ComputerName;
      Title := '选择计算机';
      BrowseInfo.lpszTitle := PChar(Pointer(Title));
      BrowseInfo.ulFlags :=BIF_BROWSEFORCOMPUTER;//;
      WindowList := DisableTaskWindows(0);
      try
        ItemIDList:=SHBrowseForFolder(BrowseInfo);
        aResult :=ItemIDList<> nil;
      finally
        EnableTaskWindows(WindowList);
      end;
      if aResult then
      begin
        SHGetPathFromIDList(ItemIDList,ComputerName);
        Result:=ComputerName;
      end
      else Result:='';
    end;
    调用:
      Edit1.Text:=PromptLookServerName(application.Handle);
    "值的珍藏"
      

  4.   

    使用NetServerEnum函数,是个API,功能很多!