问题描述
我正在尝试使用Shell将计算机放入我的工作组中
I am trying to get the computers in my workgroup using Shell
HRESULT hr = S_OK;
ULONG celtFetched;
LPITEMIDLIST pidlItems = NULL;
LPITEMIDLIST netItemIdLst = NULL;
IShellFolder* pFolder = NULL;
IEnumIDList* pEnumIds = NULL;
IShellFolder* pDesktopFolder = NULL;
LPITEMIDLIST full_pid;
hr = SHGetMalloc(&pMalloc);
hr = SHGetDesktopFolder(&pDesktopFolder);
hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMPUTERSNEARME, &netItemIdLst);
hr = pDesktopFolder->BindToObject(netItemIdLst, NULL,
IID_IShellFolder, (void **)&pFolder);
if(SUCCEEDED(hr))
{
hr = pFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &pEnumIds);
if(SUCCEEDED(hr))
{
STRRET strDisplayName;
while((hr = pEnumIds->Next(1, &pidlItems, &celtFetched)) == S_OK && celtFetched > 0)
{
hr = pFolder->GetDisplayNameOf(pidlItems, SHGDN_NORMAL, &strDisplayName);
if(SUCCEEDED(hr))
{
wprintf(L"%s\n", strDisplayName.pOleStr);
}
}
}
}
但是,这将返回计算机,媒体设备和流设备(它的名称是?).就像说,在我的工作组上有一台名为OSOFEM的计算机... STRRET::pOleStr
返回字符串OSOFEM
(这是计算机),OSOFEM
(我认为是流设备)和OSOFEM:[email protected]:
(这是Windows Media Player) ).
我的问题是如何区分哪台计算机?当然,不能使用名称,因为将始终返回两个完全相同的名称...
But this returns the Computers, Media Devices, and Streaming Devices (is that it name?). Like say, a computer is called OSOFEM on my workgroup... STRRET::pOleStr
returns strings OSOFEM
(which is the computer), OSOFEM
(I think streaming device), and OSOFEM:[email protected]:
(which is the Windows Media Player).
My question is how can I distinguish which is the Computer? Of course, there names can''t be used because two exactly the same name will always be returned...
推荐答案
这篇关于如何区分由IShellFolder的EnumObjects返回的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!