VC++利用微软mstscax.dll控件集成远程桌面
CMsRdpClientAdvancedSettings6 m_MsRdpClientAdvancedSettings(m_RemoteDesktopControl.get_AdvancedSettings());
m_RemoteDesktopControl.put_Server(_T("10.176.36.181"));
m_RemoteDesktopControl.put_UserName(_T("Leen"));
m_RemoteDesktopControl.put_DesktopHeight(800);
m_RemoteDesktopControl.put_DesktopWidth(1200);
m_RemoteDesktopControl.put_ColorDepth(32);
m_MsRdpClientAdvancedSettings.put_Compress(1);
m_MsRdpClientAdvancedSettings.put_BitmapPeristence(1);
m_MsRdpClientAdvancedSettings.put_ClearTextPassword(_T("******"));
m_MsRdpClientAdvancedSettings.put_singleConnectionTimeout(20);
m_RemoteDesktopControl.put_ConnectingText(_T("Loading..."));
m_RemoteDesktopControl.Connect();
m_MsRdpClientAdvancedSettings.put_AuthenticationLevel(2);
这句代码是提升网络身份验证用的,在 IMsRdpClientAdvancedSettings4之后追加了AuthenticationLevel属性,Win10采用的身份认证级别比较高,因此将访问端提升至更高级别即可连接。
在身份认证级别一致的情况下,假如采用证书认证,可能出现被访问端证书安装不正确的情况,会弹出以下对话框:
1.如果不想让对话框再次弹出,可以勾选“Don't ask me again...”复选框;
2.如果一次也不想看到该对话框出现,采用以下的方案:
在注册表对应路径修改如下:
Action: Create
Hive: HKEY_LOCAL_MACHINE
Key Path: SOFTWARE\Microsoft\Terminal Server Client
Value name: AuthenticationLevelOverride
Value Type: REG_DWORD
Value data: 00000000
Hexadecimal
代码修改注册表的方式如下,此处不用生成子项,所以注释生成子项的代码(此处有生成子项的代码做对比,便于区分子项和子键):
HKEY hKey = NULL;
DWORD dw = 0;
TCHAR * subKey = _T("Software\\Microsoft\\Terminal Server Client");
long resulte = RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_ALL_ACCESS, &hKey);
//1.生成子项
//resulte = RegCreateKeyEx(hKey, _T("AuthenticationLevelOverride"), 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
//2.设定子键
resulte = RegSetValueEx (hKey, _T("AuthenticationLevelOverride"), 0, REG_DWORD, (LPBYTE)&dw, sizeof(DWORD));
if (resulte != ERROR_SUCCESS)
{
AfxMessageBox("Operation register failed!");
}