windows API函数WNetGetConnection(lplocal,lpremote,lplengh);用于测试连接的网络资源(如己映射盘符),有用过的吗,可否举个例,我不会用,试了几种用法,都不成功,谢谢各位GGJJ

解决方案 »

  1.   

    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; 

      

  2.   

    http://vbworld.sxnw.gov.cn/vbapi/detail/WNetGetConnection.htm
      

  3.   

    http://codeguru.earthweb.com/network/CNetService.html接分