用WNetUseConnection; 网络邻居里访问时,就是用的这个函数。The WNetUseConnection function makes a connection to a network resource. The function can redirect a local device to a network resource.The WNetUseConnection function is similar to the WNetAddConnection3 function. The main difference is that WNetUseConnection can automatically select an unused local device to redirect to the network resource.Windows NT/2000 or later: The parameter order is as follows.DWORD WNetUseConnection( HWND hwndOwner, // owner window LPNETRESOURCE lpNetResource, // connection details LPCTSTR lpUserID, // user LPCTSTR lpPassword, // password DWORD dwFlags, // connection options LPTSTR lpAccessName, // buffer for system requests LPDWORD lpBufferSize, // buffer size LPDWORD lpResult // receives connection information ); Windows 95/98/Me: The lpUserID and lpPassword parameters are in reverse order from the order used on Windows NT/Windows 2000. Therefore, the parameter order is as follows.DWORD WNetUseConnection( HWND hwndOwner, LPNETRESOURCE lpNetResource, LPCTSTR lpPassword, LPCTSTR lpUserID, DWORD dwFlags, LPTSTR lpAccessName, LPDWORD lpBufferSize, LPDWORD lpResult );
HWND hwndOwner, // owner window
LPNETRESOURCE lpNetResource, // connection details
LPCTSTR lpUserID, // user
LPCTSTR lpPassword, // password
DWORD dwFlags, // connection options
LPTSTR lpAccessName, // buffer for system requests
LPDWORD lpBufferSize, // buffer size
LPDWORD lpResult // receives connection information
);
Windows 95/98/Me: The lpUserID and lpPassword parameters are in reverse order from the order used on Windows NT/Windows 2000. Therefore, the parameter order is as follows.DWORD WNetUseConnection(
HWND hwndOwner,
LPNETRESOURCE lpNetResource,
LPCTSTR lpPassword,
LPCTSTR lpUserID,
DWORD dwFlags,
LPTSTR lpAccessName,
LPDWORD lpBufferSize,
LPDWORD lpResult
);