I wanted to access a file share remotely and I found this post. I haven't tried it, but I think it will work. But I would like to know that is there any way to do this with Qt
in C++
(using Visual Studio 2012) ? I copied to here the relevant code from the other post:
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 ) ) );
}
Note, that I do not want to copy, just log on. So I need a function like this or an equivalent code:
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 );
*/
}