Knowledge Base Nr: 00041 Browse_Network.cpp - http://www.swe-kaiser.de
Downloads:
Win32: browse available network computers and select one
#include <SHLOBJ.H>
BOOL CMyClass::DoBrowseAndGetName(CString& strSelected)
{
BOOL bSelected = FALSE;
strSelected = "";
LPITEMIDLIST pidlRoot;
if (::SHGetSpecialFolderLocation(GetSafeHwnd(), CSIDL_NETWORK, &pidlRoot) != NULL)
return FALSE;
if (NULL == pidlRoot)
return FALSE;
char szDisplayName[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = pidlRoot;
bi.pszDisplayName = szDisplayName;
bi.lpszTitle = "Select Network Computer";
bi.ulFlags = BIF_BROWSEFORCOMPUTER;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
if (::SHBrowseForFolder(&bi) != NULL)
{
strSelected = szDisplayName;
bSelected = TRUE;
}
return bSelected;
}