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 );
*/
}