1206 ListOnlineRecourse函数的主干
来源:互联网 发布:惠普打印机驱动for mac 编辑:程序博客网 时间:2024/04/19 11:53
线程函数中的主体:
if(CheckHostStatus(strIPAddr))
{
// 获取共享资源的功能
ListOnlineRecourse(pInfo->pm_smbTree, strIPAddr, pInfo->bLevel);
}
void ListOnlineRecourse(CTreeCtrl* pTree, const CString &strIP, BYTE bLevel)
{
/* 1,入参初始化,NETRESOURCE初始化 */
DWORD dwResult, dwResultEnum;
HANDLE hEnum;
DWORD cbBuffer = 16384; // 16K is a good size
DWORD cEntries = -1; // enumerate all possible entries
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
DWORD i;
CString cstrTemp = "////" + strIP;
NETRESOURCE tNetRs;
memset(&tNetRs, 0, sizeof(NETRESOURCE));
tNetRs.dwScope = RESOURCE_GLOBALNET;
tNetRs.dwType = RESOURCETYPE_ANY;
tNetRs.dwDisplayType = RESOURCEDISPLAYTYPE_SERVER;
tNetRs.dwUsage = RESOURCEUSAGE_CONTAINER;
tNetRs.lpProvider = "Microsoft Windows Network";
char destip[64] ;
sprintf(destip, "%s", cstrTemp.GetBuffer(cstrTemp.GetLength()));
int cntDelete = strlen(destip) + 1;
tNetRs.lpRemoteName = destip;
NETRESOURCE *lpnr = &tNetRs;
// 2,检测主机是否在线
// Call the WNetOpenEnum function to begin the enumeration.
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, // all network resources
RESOURCETYPE_ANY, // all resources
0, // enumerate all resources
lpnr, // NULL first time the function is called
&hEnum); // handle to the resource
if (dwResult != NO_ERROR)
{
return;
}
//
// Call the GlobalAlloc function to allocate resources.
lpnrLocal = (LPNETRESOURCE)GlobalAlloc(GPTR, cbBuffer);
if (lpnrLocal == NULL)
{
return;
}
do
{
//
// Initialize the buffer.
//
ZeroMemory(lpnrLocal, cbBuffer);
// 3,遍历资源,并挂载树结构
// Call the WNetEnumResource function to continue
// the enumeration.
dwResultEnum = WNetEnumResource(hEnum, // resource handle
&cEntries, // defined locally as -1
lpnrLocal, // LPNETRESOURCE
&cbBuffer); // buffer size
//
// If the call succeeds, loop through the structures.
if (dwResultEnum == NO_ERROR)
{
HTREEITEM hItemParent;
if (cEntries > 0)
{
hItemParent = pTree->InsertItem(strIP, 0, 1);
}
for(i = 0; i < cEntries; i++)
{
// Call an application-defined function to
// display the contents of the NETRESOURCE structures.
// DisplayStruct(&lpnrLocal[i]);
// 将以前的打印 改进为 挂载树
CString strSmbFile(lpnrLocal[i].lpRemoteName);
strSmbFile.Delete(0, cntDelete);
HTREEITEM hItemChild = pTree->InsertItem(strSmbFile,0,1, hItemParent, TVI_LAST);
if (RESOURCEUSAGE_CONNECTABLE == lpnrLocal[i].dwUsage
&& RESOURCETYPE_DISK == lpnrLocal[i].dwType)
{
AddConnectableRcs(&lpnrLocal[i], pTree, hItemChild, bLevel);
}
}
}
// Process errors.
else if (dwResultEnum != ERROR_NO_MORE_ITEMS)
{
break;
}
}
//
// End do.
//
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
// 4,释放资源
// Call the GlobalFree function to free the memory.
//
GlobalFree((HGLOBAL)lpnrLocal);
//
// Call WNetCloseEnum to end the enumeration.
//
dwResult = WNetCloseEnum(hEnum);
if(dwResult != NO_ERROR)
{
//
// Process errors.
//
return;
}
}
- 1206 ListOnlineRecourse函数的主干
- SVN 分支主干的合并
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- SVN的分支、主干合并的使用说明
- 四个主干类的介绍 ( Android )
- 主干开发,“关上”未完成的功能
- SVN 主干和分支的合并
- SVN 主干和分支的合并
- JWFD科技树的主干进化点
- SVN 主干与分支的合并
- svn主干和分支的切换
- SVN分支与主干的合并
- Cornerstore的创建分支与合并主干
- 这几天的学习
- 转一篇介绍开发嵌入式经验的文章,写得不错,比较中肯,适合一看。
- ORACLE将分隔数据转换为多值IN列表
- 将两位十进制的书转换成八位纯二进制数
- asp.net 页面传值
- 1206 ListOnlineRecourse函数的主干
- Windows程序设计——Windows操作系统发展简史
- 屏幕增强
- Chain Of Responsibility 职责链模式
- SQL Server 安装问题
- 点击按钮时弹出另一个能控制大小的页面,并将某些值通过POST方式传给这个弹出的窗口
- C语言难点专题——数组和指针
- 本博客已搬家
- 无upload组件上传文件