如何使用 QAxContainer.QAxWidget() 和 PyQt 登录到 Microsoft RDP 客户端控件



大家!请帮助我使用 Python 和 PyQt 中的QAxContainer.QAxWidget()连接到 Microsoft RDP 客户端控件...

这是我的代码片段:

QAx_RDP = QAxContainer.QAxWidget(self)
QAx_RDP.setControl('{54d38bf7-b1ef-4479-9674-1bd6ea465258}')
QAx_RDP.setProperty('Server', 'xxx.xxx.xxx.xxx')
QAx_RDP.setProperty('UserName', 'user')
QAx_RDP.Connect()

一切正常,但我需要手动输入密码...我的 QAx_RDP 对象具有 AdvancedSettings2.ClearTextPassword 属性,但无法访问此属性。我尝试以两种方式做到这一点:

 1. QAx_RDP.AdvancedSettings2.ClearTextPassword = "password"
 2. QAx_RDP.setProperty('ClearTextPassword', "password")

它们都不起作用。如何以编程方式发送密码?

谢谢!

我只对C++这样做了。

导入的 RDP mstscax.dll带有 dumpcpp 工具。或者,您可以使用 TYPELIBS = $$PWD/rdp/mstscax project.pro.dll 在文件中执行此操作,并通过将它们包含在项目中来使用生成的定义(请参阅生成的文件)。然后从MSTSCLib::MsRdpClient8NotSafeForScripting(导入的定义)中创建ActiveX对象rdpWidget。您也可以使用其他版本。

// used parent widget for embedding ActiveX in it -- this
auto* rdpWidget = new MSTSCLib::MsRdpClient8NotSafeForScripting(this);

也称为:

rdpWidget->show(); // what starts with lower-case is Qt method and uppercase is COM method
rdpWidget->SetUserName(userName);
MSTSCLib::IMsRdpClientAdvancedSettings* pAdvSettings = rdpWidget->AdvancedSettings2();
pAdvSettings->SetClearTextPassword(password);
rdpWidget->Connect(); // don't forget!

另外,还有相当多的事件处理是用于特定目的的。在简短的回复中涵盖所有内容有点困难,但最终来源是MSDN。所有这些例子只是几行,但实际上还有更多。如果您有具体问题,可以单独提问。

编辑:为询问如何处理dumpcpp导入的另一个用户更新。不要直接包含它,而是手动完成:

// Mind the structure of at least one RDP-related file in the project
// All includes
#define QAX_DUMPCPP_MSTSCLIB_NOINLINES // Important!
#include "mstscax.h" // see .pro file for TYPELIBS = $$PWD/rdp/mstscax.dll
// My code as above

// bottom of file: include own import file with all remaining functions
// with compile errors excluded by hand there is a handful of those
// complaining about private constructor of QObject or so
#include "mstscax_impl.cpp"

最新更新