2015-04-16 845 views
0

每个人都登录到Microsoft RDP Client Control ActiveX!请帮我带连接到Microsoft RDP客户端控件使用QAxContainer.QAxWidget()在Python和PyQt的...如何使用QAxContainer.QAxWidget()和PyQt

这是我的代码片段:

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") 

它们都不工作。我怎样才能以编程方式发送密码?

谢谢!

回答

0

我只用C++做过。

用dumpcpp工具导入RDP mstscax.dll。或者你可以在project.pro文件中使用TYPELIBS = $$ PWD/rdp/mstscax.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" 
+0

嗨,我已经使用dumpcpp所产生的.h和.cpp文件(如mstsclib.h和mstsclib.cpp)为mstscax.dll的。 但是当我包含mstsclib.h头文件时,在我的qt项目中出现了很多错误。 012,我认为这些代码会导致这些错误: // stub for vtable-only interface class IMsRdpClientNonScriptable:public QAxObject {}; 你有没有遇到过这些错误?或者你能上传你的关于mstscax.dll的代码吗?如果你能 告诉我你的电子邮件地址,我会很满意。谢谢 – user2848932

+0

@ user2848932:我已经更新了我的答案。介意QAX_DUMPCPP_MSTSCLIB_NOINLINES。 – AlexanderVX

+0

感谢您的帮助!我按照你所说的完成了,但我仍然得到错误。 我包括mstscax.h并添加#define QAX_DUMPCPP_MSTSCLIB_NOINLINES后,发生lnk2001无法解析的外部符号错误。 我认为这个错误是与.cpp文件关联的。是你自己创建的文件mstscax_impl.cpp吗? 我可以通过电子邮件与您沟通吗?我的电子邮件是[email protected]。再次感谢你 ! – user2848932