Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用Qt,C+编程登录(wnetadconnection)到文件共享+;?_C++_Qt_Qt5 - Fatal编程技术网

C++ 如何使用Qt,C+编程登录(wnetadconnection)到文件共享+;?

C++ 如何使用Qt,C+编程登录(wnetadconnection)到文件共享+;?,c++,qt,qt5,C++,Qt,Qt5,我想远程访问文件共享,我找到了。我还没试过,但我想它会管用的。但是我想知道,在C++中使用Qt有什么方法可以做到这一点(使用Visual Studio 2012)?我将另一篇文章中的相关代码复制到这里: public static void CopyFile( string from, string shareName, string username,

我想远程访问文件共享,我找到了。我还没试过,但我想它会管用的。但是我想知道,在
C++
中使用
Qt
有什么方法可以做到这一点(使用Visual Studio 2012)?我将另一篇文章中的相关代码复制到这里:

public static void CopyFile( string from,
                             string shareName,
                             string username,
                             string password )
{
    NETRESOURCE nr = new NETRESOURCE();
    nr.dwType = ResourceType.RESOURCETYPE_DISK;
    nr.lpLocalName = null;
    nr.lpRemoteName = shareName;
    nr.lpProvider = null;

    int result = WNetAddConnection2( nr,  password,  username, 0 );

    System.IO.File.Copy( from,
                         System.IO.Path.Combine( shareName,
                                                 System.IO.Path.GetFileName( from ) ) );
}
请注意,我不想复制,只需登录即可。所以我需要这样一个函数或一个等价的代码:

public static void CopyFile( const std::string& shareName,
                             const std::string& username,
                             const std::string& password )
{
    /*
    NETRESOURCE nr = new NETRESOURCE();
    nr.dwType = ResourceType.RESOURCETYPE_DISK;
    nr.lpLocalName = null;
    nr.lpRemoteName = shareName;
    nr.lpProvider = null;

    int result = WNetAddConnection2( nr,  password,  username, 0 );
    */
}