


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!");
}