NowCan及各位对系统熟系的朋友请来帮忙。
以下代码是从NowCan的个人主页上copy下来并改的,功能是查找网络上的所有计算机。能在win98,win2000上执行,到winnt 4.0(sp6)就执行不了,头晕中。
代码:
--------------------------------------------------------------------
bool TfrmMain::Enumerate(LPNETRESOURCE lpNetRC_p)
{
//查找网上邻居的所有计算机
HANDLE hEnum = 0;
DWORD dwScope = RESOURCE_GLOBALNET ;
DWORD dwType = RESOURCETYPE_ANY ;
DWORD dwResult = WNetOpenEnum(
dwScope, // scope of enumeration
dwType, // resource types to list
0, // enumerate all resources
lpNetRC_p, // pointer to resource structure (NULL at first time)
&hEnum // handle to resource
);
if (dwResult != NO_ERROR)
return false;
DWORD dwBuffer = 16384 ; // 16K is reasonable size
DWORD dwEntries = 0xFFFFFFFF ; // enumerate all possible entries
LPNETRESOURCE lpnrLocal = 0;
bool bRet = true;
AnsiString sComputerName;
try
{
do
{
// first allocate buffer for NETRESOURCE structures ...
lpnrLocal = (LPNETRESOURCE) GlobalAlloc( GPTR, dwBuffer ) ;
dwResult = WNetEnumResource(
hEnum, // resource-handle
&dwEntries,
lpnrLocal,
&dwBuffer
);
if (dwResult == NO_ERROR)
{
for (DWORD i=0; i<dwEntries; i++)
{
if (RESOURCEUSAGE_CONTAINER ==
(lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER) &&
lpnrLocal[i].dwDisplayType != RESOURCEDISPLAYTYPE_SERVER)
{
if (!Enumerate(&lpnrLocal[i])) {
throw Exception("在网上查找计算机失败!");
}
}else{
sComputerName = lpnrLocal[i].lpRemoteName; //计算机名
sComputerName.Delete(1, 2);
// AddListviewItem(sComputerName, lpnrLocal[i].lpComment);
}
}
}
} while (dwResult != ERROR_NO_MORE_ITEMS);
}catch(...){
bRet = false;
}
if (lpnrLocal)
GlobalFree((HGLOBAL)lpnrLocal) ;
WNetCloseEnum(hEnum) ;
return bRet;
}
代码:
--------------------------------------------------------------------
bool TfrmMain::Enumerate(LPNETRESOURCE lpNetRC_p)
{
//查找网上邻居的所有计算机
HANDLE hEnum = 0;
DWORD dwScope = RESOURCE_GLOBALNET ;
DWORD dwType = RESOURCETYPE_ANY ;
DWORD dwResult = WNetOpenEnum(
dwScope, // scope of enumeration
dwType, // resource types to list
0, // enumerate all resources
lpNetRC_p, // pointer to resource structure (NULL at first time)
&hEnum // handle to resource
);
if (dwResult != NO_ERROR)
return false;
DWORD dwBuffer = 16384 ; // 16K is reasonable size
DWORD dwEntries = 0xFFFFFFFF ; // enumerate all possible entries
LPNETRESOURCE lpnrLocal = 0;
bool bRet = true;
AnsiString sComputerName;
try
{
do
{
// first allocate buffer for NETRESOURCE structures ...
lpnrLocal = (LPNETRESOURCE) GlobalAlloc( GPTR, dwBuffer ) ;
dwResult = WNetEnumResource(
hEnum, // resource-handle
&dwEntries,
lpnrLocal,
&dwBuffer
);
if (dwResult == NO_ERROR)
{
for (DWORD i=0; i<dwEntries; i++)
{
if (RESOURCEUSAGE_CONTAINER ==
(lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER) &&
lpnrLocal[i].dwDisplayType != RESOURCEDISPLAYTYPE_SERVER)
{
if (!Enumerate(&lpnrLocal[i])) {
throw Exception("在网上查找计算机失败!");
}
}else{
sComputerName = lpnrLocal[i].lpRemoteName; //计算机名
sComputerName.Delete(1, 2);
// AddListviewItem(sComputerName, lpnrLocal[i].lpComment);
}
}
}
} while (dwResult != ERROR_NO_MORE_ITEMS);
}catch(...){
bRet = false;
}
if (lpnrLocal)
GlobalFree((HGLOBAL)lpnrLocal) ;
WNetCloseEnum(hEnum) ;
return bRet;
}
...全文
相关推荐
前端开发基于history.js的HTML5与HTML4浏览器兼容方案:单页应用无刷新历史状态管理技术实现-5Z6jeSqI1792158476
内容概要:本文系统介绍了如何利用history.js实现单页应用(SPA)在HTML5c与HTML4浏览器间s草错发的无缝历史状态管理。通过封装原生History API并在不支持的浏览器中自动降级为哈希路由,history.js解决了因浏览器兼容性导致的后退按钮失效、URL混乱等问题。文章详细讲解了其核心机制,包括状态对象管理、自动模式切换(HTML5 pushState vs HTML4 哈希)、状态数据持久化以及针,对Safari、IE等浏\览器的兼容性修复方案,并提供了从入门到实战的完整示例,涵盖初始化、事,件监听、页面加载及性能优化技巧。;5Z6jeSqI1792158476 sdhmgggw168.com www.shangliangwangye.com www.sdbing.net migu.blsxex.abxlbz.sc.cn www.safespeed.net.cn
高校如何通过科技报告服务提升技术转移转化效率?.docx
科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。
科技服务机构如何提升服务大企业的技术诊断能力?.docx
科技服务机构如何提升服务大企业的技术诊断能力?
央企如何通过市场数据优化数字化转型战略?.docx
央企如何通过市场数据优化数字化转型战略?
园区如何通过数据分析实现精准招商引资?.docx
园区如何通过数据分析实现精准招商引资?


Windows SDK/API
