By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Using tlb/dll on Windows (VARIANT data type returned)

P: 2
I have C++ code to import a .tlb and use a .dll that has functions that return VARIANT types and accepts BSTRs (bstrings). I have seen that python has modules that can manipulate VARIANTs and BSTRs in the win32com or comtypes.automation packages. I began to use Boost.Python to script some of my code. I tried to send the VARIANT back to python by having the extension module's functions return a VARIANT or VARIANT*; I even tried _variant_t. In python, I used the comtypes.automation.VARIANT type like so:
varvalue = VARIANT(cppextension.function_call())
But this did not work :(

Qs:
Can I return the VARIANT using Boost.Python?
If not, is there another way?
Also, how can I use the tlb/dll directly in python? Is it similar to in C++, where I import the tlb and then can access the dll's namespace?

Any help would be appreciated!
Dec 2 '07 #1
Share this Question
Share on Google+
1 Reply


bartonc
Expert 5K+
P: 6,596
I have C++ code to import a .tlb and use a .dll that has functions that return VARIANT types and accepts BSTRs (bstrings). I have seen that python has modules that can manipulate VARIANTs and BSTRs in the win32com or comtypes.automation packages. I began to use Boost.Python to script some of my code. I tried to send the VARIANT back to python by having the extension module's functions return a VARIANT or VARIANT*; I even tried _variant_t. In python, I used the comtypes.automation.VARIANT type like so:
varvalue = VARIANT(cppextension.function_call())
But this did not work :(

Qs:
Can I return the VARIANT using Boost.Python?
If not, is there another way?
Also, how can I use the tlb/dll directly in python? Is it similar to in C++, where I import the tlb and then can access the dll's namespace?

Any help would be appreciated!
The win32 package has support for this type of conversion. The comtypes module (package?) may also have what you are looking for.
Dec 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.