用过windows API函数WNetGetConnection(lplocal,lpremote,lplengh);请进
windows API函数WNetGetConnection(lplocal,lpremote,lplengh);用于测试连接的网络资源(如己映射盘符),有用过的吗,可否举个例,我不会用,试了几种用法,都不成功,谢谢各位GGJJ 问题点数:100、回复次数:4Top
1 楼arvid_gs(west)回复于 2003-12-03 09:00:38 得分 40
To retrieve the name of the network resource associated with a local device, an application can call the WNetGetConnection function, as shown in the following example. The sample calls an application-defined error handler to process errors, and the TextOut function for printing.
CHAR szDeviceName[80];
DWORD dwResult, cchBuff = sizeof(szDeviceName);
// Call the WNetGetConnection function.
//
dwResult = WNetGetConnection("z:",
(LPSTR) szDeviceName,
&cchBuff);
switch (dwResult)
{
//
// Print the connection name or process errors.
//
case NO_ERROR:
TextOut(hdc, 10, 10, (LPSTR) szDeviceName,
lstrlen((LPSTR) szDeviceName));
break;
//
// The device is not a redirected device.
//
case ERROR_NOT_CONNECTED:
TextOut(hdc, 10, 10, "Device z: not connected.", 24);
//
// The device is not currently connected,
// but it is a persistent connection.
//
case ERROR_CONNECTION_UNAVAIL:
TextOut(hdc, 10, 10, "Connection unavailable.", 23);
//
// Call an application-defined error handler.
//
default:
NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetGetConnection");
return FALSE;
}
Top
2 楼yezi7(飘零的叶子)回复于 2003-12-03 09:34:17 得分 0
http://vbworld.sxnw.gov.cn/vbapi/detail/WNetGetConnection.htmTop
3 楼SmallBigCat(乱花渐欲迷人眼)回复于 2003-12-03 09:55:56 得分 60
http://codeguru.earthweb.com/network/CNetService.html
接分Top
4 楼zongzi7(我爱吃粽子)回复于 2003-12-03 12:58:54 得分 0
upTop




