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

Python 如何使用QAxContainer.QAxWidget()和PyQt登录到Microsoft RDP客户端控件ActiveX,python,qt,pyqt,activex,Python,Qt,Pyqt,Activex,各位!!请帮助我使用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('Use

各位!!请帮助我使用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++。< /P> 使用dumpcpp工具导入了RDP mstscax.dll。或者,您可以在project.pro文件中使用TYPELIBS=$$PWD/rdp/mstscax.dll执行此操作,并通过将生成的定义包含在项目中来使用它们。请参见生成的文件。然后从MSTSCLib::MSRDPClient8NotSafeForScript导入的定义中创建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!
此外,还有很多用于特定目的的事件处理。在简短的回复中涵盖所有内容有点困难,但最终的来源是。所有这些例子只是几行,但实际上还有更多。如果你有具体的问题,你可以单独问

编辑:另一个询问如何处理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"

您好,我已经使用dumpcpp为mstscax.dll生成了.h和.cpp文件,如mstsclib.h和mstsclib.cpp。但当我包含mstsclib.h头文件时,我的qt项目中会出现许多错误。谷歌搜索之后,我认为这些代码会导致以下错误://stub for vtable-only接口类IMsTscNonScriptable:public-QAxObject{};//vtable-only接口类IMsRdpClientNonScriptable的存根:public QAxObject{};你曾经遇到过这些错误吗?或者你可以上传关于mstscax.dll的代码吗?如果您能告诉我您的电子邮件地址,我将不胜感激。thanks@user2848932:我已经更新了我的答案。当心QAX_DUMPCPP_MSTSCLIB_noinline.谢谢你的帮助!我已经照你说的做了,但还是有错误。在我包含mstscax.h并添加define QAX_DUMPCPP_MSTSCLIB_noinline之后,会发生lnk2001未解析的外部符号错误。我认为这个错误与.cpp文件有关。文件mstscax_impl.cpp是您自己制作的吗?我可以通过电子邮件与你沟通吗?我的电子邮件是libin0410@126.com. 再次感谢你!