获取网上邻居及其资源
来源:互联网 发布:咏春实战 知乎 编辑:程序博客网 时间:2024/06/06 23:15
::OnTest()
{
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->ResetContent();
EnumNet(NULL, 0);
}
::EnumNet(NETRESOURCE* pResource, int nItem)
{
HANDLE hEnum = NULL;
DWORD dwResult = 0;
//打开网上资源的枚举
dwResult = WNetOpenEnum(
RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
pResource,
&hEnum);
if (dwResult != NO_ERROR)
{
return;
}
DWORD nCount = -1;
DWORD nSize = 16384;
pResource = (NETRESOURCE*)new BYTE[nSize];
do
{
ZeroMemory(pResource, nSize);
//枚举网上资源
dwResult = WNetEnumResource(
hEnum,
&nCount,
pResource,
&nSize);
if (dwResult == NO_ERROR)
{
for (UINT n = 0 ; n < nCount; n++)
{
ShowNet(&pResource[n], nItem);
//如果网络资源是容器资源则递归调用枚举函数
if ((pResource[n].dwUsage &RESOURCEUSAGE_CONTAINER)
== RESOURCEUSAGE_CONTAINER)
{
EnumNet(&pResource[n], nItem + 1);
}
}
}
else if(dwResult != ERROR_NO_MORE_ITEMS)
{
break;
}
} while(dwResult != ERROR_NO_MORE_ITEMS);
delete[] pResource;
//关闭网上资源的枚举
WNetCloseEnum(hEnum);
}
::ShowNet(NETRESOURCE* pResource, int nItem)
{
CString strText = _T("");
strText += _T("");
strText += pResource->lpRemoteName;
strText += _T("");
strText += pResource->lpLocalName;
strText += _T("");
strText += pResource->lpComment;
strText += _T("");
for (int n = 0; n < nItem; n++)
{
strText = _T(" ") + strText;
}
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->AddString(strText);
}
{
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->ResetContent();
EnumNet(NULL, 0);
}
::EnumNet(NETRESOURCE* pResource, int nItem)
{
HANDLE hEnum = NULL;
DWORD dwResult = 0;
//打开网上资源的枚举
dwResult = WNetOpenEnum(
RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0,
pResource,
&hEnum);
if (dwResult != NO_ERROR)
{
return;
}
DWORD nCount = -1;
DWORD nSize = 16384;
pResource = (NETRESOURCE*)new BYTE[nSize];
do
{
ZeroMemory(pResource, nSize);
//枚举网上资源
dwResult = WNetEnumResource(
hEnum,
&nCount,
pResource,
&nSize);
if (dwResult == NO_ERROR)
{
for (UINT n = 0 ; n < nCount; n++)
{
ShowNet(&pResource[n], nItem);
//如果网络资源是容器资源则递归调用枚举函数
if ((pResource[n].dwUsage &RESOURCEUSAGE_CONTAINER)
== RESOURCEUSAGE_CONTAINER)
{
EnumNet(&pResource[n], nItem + 1);
}
}
}
else if(dwResult != ERROR_NO_MORE_ITEMS)
{
break;
}
} while(dwResult != ERROR_NO_MORE_ITEMS);
delete[] pResource;
//关闭网上资源的枚举
WNetCloseEnum(hEnum);
}
::ShowNet(NETRESOURCE* pResource, int nItem)
{
CString strText = _T("");
strText += _T("");
strText += pResource->lpRemoteName;
strText += _T("");
strText += pResource->lpLocalName;
strText += _T("");
strText += pResource->lpComment;
strText += _T("");
for (int n = 0; n < nItem; n++)
{
strText = _T(" ") + strText;
}
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->AddString(strText);
}
- 获取网上邻居及其资源
- 网上邻居
- Android应用程序目录结构及其资源的获取
- 菜单及其他资源
- 免费文档资源:Win XP 打不开网上邻居的几种处理方法
- 网上邻居无法访问
- 网上邻居 常见问题
- 网上邻居属性
- 网上邻居文件夹
- Android字符串资源及其格式化
- Android字符串资源及其格式化
- Android字符串资源及其格式化
- Android-字符串资源及其格式化
- Android字符串资源及其格式化
- Android字符串资源及其格式化
- VCP及其改进算法资源
- Android字符串资源及其格式化
- R语言及其学习资源
- PHP AES256加密算法
- 观察者模式的理解(感觉还好,有时间看下 Button的监听过程)
- auto_ptr的简单实现
- ftp命令详解
- 解决Django网站的点击次数统计功能
- 获取网上邻居及其资源
- RQNOJ 598(用b记录元素是否在队中)
- 一个有关Java中List的低级错误
- 计算机知识
- i2c - gpio
- 【Poco】Poco::Format的例子
- 测试网站各项性能的31 个免费在线工具
- 对话框show问题,需要removeView,
- Android logcat 使用方法