1,如果发现是可以连接的资源,进入函数AddConnectableRcs,深入一层遍历文件名。
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);
}
}
2,AddConnectableRcs的定义:
注意使用WNetCancelConnection2,有开有关。
3,FindFirstFile函数返回了错误,使用GetLastError得到错误码是53
hFind = FindFirstFile(lpConnectable->lpRemoteName, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
DWORD dwErrorCode = GetLastError();
printf ("Invalid file handle. Error is %u/n", dwErrorCode);
return (-1);
}
4,使用system error codes在msdn这索引
ERROR_BAD_NETPATH 53 The network path was not found.
这个错误并不少见,明天具体看看原因。