首页  编辑  

调用网上邻居搜查在线电脑的API函数

Tags: /超级猛料/Network.网络通讯/LAN/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` Try to use it

//

// Display a dialog box allowing the user to choose a computer (not a drive,

// printer, etc. but just a computer in the network).

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box,  e.g. Choose Cache Server

//

// Returns: computer chosen

//          empty string on error or no computer chosen

//

function ChooseComputer(parent_window: HWND; caption: String): String;

begin

   Result:=NetworkBrowsing(parent_window, caption, BIF_BROWSEFORCOMPUTER);

end;

//

// Display a dialog box allowing the user to choose a share on a network

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box, e.g. Choose share

//

// Returns: share chosen

//          empty string on error or no share chosen

//

function ChooseShare(parent_window: HWND; caption: String): String;

begin

   Result:=NetworkBrowsing(parent_window, caption, BIF_RETURNONLYFSDIRS);

end;

//

// Display a dialog box allowing the user to choose a computer, network drive,

// etc.

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box, e.g. Choose Cache Server

//      what to browse for (e.g. BIF_BROWSEFORCOMPUTER for computers)

//

// Returns: computer chosen

//          empty string on error or no computer chosen

//

// Note: typical browse_for values are

//

//  BIF_RETURNONLYFSDIRS for networked folders

//  BIF_BROWSEFORCOMPUTER for computers

//

function NetworkBrowsing(parent_window: HWND; caption: String; browse_for: Integer): String;

var lpbi: _browseInfo;

   dn: String;

   idlist: ITEMIDLIST;

   ridlist: PITEMIDLIST;

   ppMalloc: IMalloc;

begin

   try

       // Get pointer to network root

       SHGetSpecialFolderLocation(parent_window, CSIDL_NETWORK, PITEMIDLIST(idlist));

       // Initialise & display dialog box

       lpbi.hwndOwner:=parent_window;

       lpbi.pidlRoot:=PITEMIDLIST(idlist);

       SetLength(dn, 255);

       lpbi.pszDisplayName:=PChar(dn);

       lpbi.lpszTitle:=PChar(caption);

       lpbi.ulFlags:=browse_for;

       lpbi.lpfn:=nil;

       ridlist:=SHBrowseForFolder(lpbi);

       // Store the resuls

{xxx

       if browse_for <> BIF_BROWSEFORCOMPUTER then begin

         // Return the complete network path

         SetLength(Result, 255);

         SHGetPathFromIDList(ridlist, PChar(Result));

       end else

}

         // Return only the name of the 'thing' selected

         Result:=lpbi.pszDisplayName;

       // Free memory

       if ridlist=nil then

         Result:=''

       else begin

         SHGetMalloc(ppMalloc);

         ppMalloc.Free(ridlist);

       end;

   except

       // Oops

       Result:='';

   end;

end;

回复人:tibetty(2000-10-5 14:45:00)  得0分

我也要,请发到; tibetty99@etang.com 谢了

回复人:tibetty(2000-10-5 14:48:00)  得0分

我也要,请发到; tibetty99@etang.com 谢了

回复人:Lionheart(2000-10-6 0:11:00)  得0分

试试看

//

// Display a dialog box allowing the user to choose a computer, network drive,

// etc.

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box, e.g. Choose Cache Server

//      what to browse for (e.g. BIF_BROWSEFORCOMPUTER for computers)

//

// Returns: computer chosen

//          empty string on error or no computer chosen

//

// Note: typical browse_for values are

//

//  BIF_RETURNONLYFSDIRS for networked folders

//  BIF_BROWSEFORCOMPUTER for computers

//

function NetworkBrowsing(parent_window: HWND; caption: String; browse_for: Integer): String;

var

 lpbi: _browseInfo;

 dn: String;

 idlist: ITEMIDLIST;

 ridlist: PITEMIDLIST;

 ppMalloc: IMalloc;

begin

 try

   // Get pointer to network root

   SHGetSpecialFolderLocation(parent_window, CSIDL_NETWORK, PITEMIDLIST(idlist));

   // Initialise & display dialog box

   lpbi.hwndOwner:=parent_window;

   lpbi.pidlRoot:=PITEMIDLIST(idlist);

   SetLength(dn, 255);

   lpbi.pszDisplayName:=PChar(dn);

   lpbi.lpszTitle:=PChar(caption);

   lpbi.ulFlags:=browse_for;

   lpbi.lpfn:=nil;

   ridlist:=SHBrowseForFolder(lpbi);

   // Store the resuls

   {xxx

   if browse_for <> BIF_BROWSEFORCOMPUTER then begin

   // Return the complete network path

   SetLength(Result, 255);

   SHGetPathFromIDList(ridlist, PChar(Result));

   end else

   }

   // Return only the name of the 'thing' selected

   Result:=lpbi.pszDisplayName;

   // Free memory

   if ridlist=nil then

     Result:=''

   else begin

     SHGetMalloc(ppMalloc);

     ppMalloc.Free(ridlist);

   end;

 except

   // Oops

   Result:='';

 end;

end;

//

// Display a dialog box allowing the user to choose a computer (not a drive,

// printer, etc. but just a computer in the network).

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box,  e.g. Choose Cache Server

//

// Returns: computer chosen

//          empty string on error or no computer chosen

//

function ChooseComputer(parent_window: HWND; caption: String): String;

begin

 Result:=NetworkBrowsing(parent_window, caption, BIF_BROWSEFORCOMPUTER);

end;

//

// Display a dialog box allowing the user to choose a share on a network

//

// Args: parent window (usually TForm.Handle)

//      caption to display on the dialog box, e.g. Choose share

//

// Returns: share chosen

//          empty string on error or no share chosen

//

function ChooseShare(parent_window: HWND; caption: String): String;

begin

 Result:=NetworkBrowsing(parent_window, caption, BIF_RETURNONLYFSDIRS);

end;