代码如下:
NETRESOURCE netres; 
netres.dwScope=RESOURCE_GLOBALNET; 
netres.dwType=RESOURCETYPE_ANY; 
netres.dwDisplayType=RESOURCEDISPLAYTYPE_GENERIC; 
netres.dwUsage=RESOURCEUSAGE_CONNECTABLE; 
netres.lpLocalName="H:"; 
netres.lpRemoteName="\\abc\abc"; 
netres.lpComment=NULL; 
netres.lpProvider=NULL; DWORD rslt=WNetAddConnection2(&netres, NULL, NULL, CONNECT_UPDATE_PROFILE); WNetAddConnection2的参数dwFlags: 如果设为CONNECT_UPDATE_PROFILE, 则表示永久连接,在XP里刚映射好, 在资源管理器里看到\\abc\abc被映射到H:了,
但是我重启机器后, 再打开资源管理器, 却看不到该驱动H:了在cmd中用net use命令看, 该连接是存在的, 但是资源管理器里却看不到我用2000的机器试了一下, 是好的, 只是系统不同, 为什么一个重启以后资源管理器里可以看见该驱动, 另一个就看不到呢,
我建立的是永久连接啊另外XP中, 资源管理器里手动映射驱动, 重启机器, 资源管理器里还是可以看见的

解决方案 »

  1.   

    CONNECT_UPDATE_PROFILE
     The network resource connection should be remembered. If this bit flag is set, the operating system automatically attempts to restore the connection when the user logs on.The operating system remembers only successful connections that redirect local devices. It does not remember connections that are unsuccessful or deviceless connections. (A deviceless connection occurs when the lpLocalName member is NULL or points to an empty string.)If this bit flag is clear, the operating system does not automatically restore the connection at logon.