Network Enumerations (3) | CodeGuru

Network Enumerations (3)

Having seen the 2 previous offerings which front load the enumeration in such a way that on a large or awkward network they can take a long time to return, I took a look at the browse for folder code which was rather cumbersome but with some tinkering reduced it to the following: LPITEMIDLIST pidlRoot […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 16, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Having seen the 2 previous offerings which front load the enumeration in
such a way that on a large or awkward network they can take a long time to
return, I took a look at the browse for folder code which was rather
cumbersome but with some tinkering reduced it to the following:

LPITEMIDLIST pidlRoot = NULL;
SHGetSpecialFolderLocation(GetSafeHwnd(), CSIDL_NETWORK, &pidlRoot);
CString strDisplayName;
BROWSEINFO bi;
memset(&bi, 0, sizeof(BROWSEINFO));
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = pidlRoot;
bi.pszDisplayName = strDisplayName.GetBuffer(MAX_PATH + 1);
bi.lpszTitle = “Find computer”;
bi.ulFlags = BIF_BROWSEFORCOMPUTER;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
strDisplayName.ReleaseBuffer();
if(pidl)
{
    m_machine = strDisplayName;
    UpdateData(FALSE);
}
IMalloc *pMalloc = NULL;
SHGetMalloc(&pMalloc);
pMalloc->Free(pidlRoot);

Create a dialog box with a CEdit control on it. Create a member variable for
this CEdit called m_machine. Attach the code above to a button (any other
than OK or Cancel).

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.