thanks

解决方案 »

  1.   

    我用了上面的函数
    具体程序:
    NETRESOURCE netr;
    TCHAR netBuf[50]={0};
    memset(&netr,0,sizeof(NETRESOURCE));
    wsprintf(netBuf,"\\\\192.168.1.166\\");
    netr.dwScope = RESOURCE_GLOBALNET;
    netr.dwType  = RESOURCETYPE_ANY;
    netr.lpLocalName = "";
    netr.lpRemoteName = netBuf;
    netr.lpProvider = NULL;
        WNetAddConnection2(&netr,
                 (LPSTR)"guest",
        (LPSTR)"guest",
        CONNECT_UPDATE_PROFILE);包含了头文件Winnetwk.h
    但是调试总是出错
    -------------------Configuration: netconnect - Win32 Debug--------------------
    Compiling...
    MainFrm.cpp
    Linking...
    NetConnect1.obj : error LNK2001: unresolved external symbol _WNetAddConnection2A@16
    Debug/netconnect.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    Creating browse info file...netconnect.exe - 2 error(s), 0 warning(s)谢谢
      

  2.   

    project--setting--link
    加上mpr.lib