473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

COM :: VARIANT -eek

Hi, all.

Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)

Cheers in advance,
Matt
Jul 18 '05 #1
5 3505
Matt Smith wrote:
Hi, all.

Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)


Unfortunately, you really can't do this in a clean way. The best thing
to do is to ensure "makepy" has been run for your COM object, and the
right magic should always happen.

Mark.

Jul 18 '05 #2
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...
Matt Smith wrote:
Hi, all.

Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)


Unfortunately, you really can't do this in a clean way. The best thing
to do is to ensure "makepy" has been run for your COM object, and the
right magic should always happen.

Mark.


Hi, thanks for the reply,

My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?

Cheers,
Matt.

p.s. How do I include the generated makepy file into my code ?
Jul 18 '05 #3
Matt Smith wrote:
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>... My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?
These type libraries are in the registry. You may be able to pass the
filename on the commandline to makepy.
p.s. How do I include the generated makepy file into my code ?


In generaly, you just need to generate the file and do nothing else. At
runtime, Python will see these generated files and automatically use them.

I don't know how that will go with your type library though.

Mark

Jul 18 '05 #4
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...
Matt Smith wrote:
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...

My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?


These type libraries are in the registry. You may be able to pass the
filename on the commandline to makepy.
p.s. How do I include the generated makepy file into my code ?


In generaly, you just need to generate the file and do nothing else. At
runtime, Python will see these generated files and automatically use them.

I don't know how that will go with your type library though.

Mark


Hi again,

I had to register the .tlb file (as it didnt do it automatically at
installation [don't know why]) using a vb .tlb registration script,
which worked fine and now I have a lovily makepy.py generated file for
my .tlb file.

My problem is now this, When I try to run the file (in pythonwins
interactive window) using the code:

from win32com.client include gencache
gencache.EnsureModule('{AF684923-D245-11D3-8DE8-00A024ACAB85x0x1x0}',
0, 1, 0)

pythonwin returns the error:

ImportError: No module named
gen_py.AF684923-D245-11D3-8DE8-00A024ACAB85x0x1x0

I have tested it with other makepy.py generated files and they all
return the same error. Do I need to tell python where to find these
makepy files? or is there some other reason as to why it does not want
to use ANY makepy.py files

thanks for all the help,
matt.
Jul 18 '05 #5
hi again, sorry about all these updates but cant remember what I
posted in the last message and google ahsnt updated yet :/.

My current probelm is that I have generated a makepy file and then run
ensureModule on it to ensure early binding. However when I came to run
Dispatch it still ran with late binding :(. If i ran the script with
ensureDispatch would that help (instead of normal client.Dispatch that
is)

thanks again,
matt.

p.s. forgot to post the .tlb register website address here it is:

http://www.vbaccelerator.com/codelib/tlb/vbregtlb.htm
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt Smith | last post by:
Hi, all. Just a quick question, when setting a COM process to read a value from a pre-defined register index, I think, I have to change the variable that the value will be returned to (as I have...
1
by: C. N. Sridhar | last post by:
Hi, I'm writing a wrapper to a win32 dll in C#. I need to call a method in DLL which has a Variant type reference parameter. How to marshal variant type from win32 (unmanaged code) to C#...
8
by: MLH | last post by:
A97 HELP shows the proper syntax for using Nz as Nz(variant) I'm wondering what to expect from potential past misuse I've made. For example, consider the following... Private Sub...
19
by: Jon Davis | last post by:
Hi guys! Just wanted to let you all know that I created a Variant structure, inspired by the old VB6 days. This is written in C#, but you can build a CLR/.NET class library assembly and reference...
0
by: .::alex::. | last post by:
Hello, Maybe you already guess the problem. I have a COM with a method in a Interface like that: HRESULT GetArray(VARIANT *pVal); so this method will return a VARIANT. This VARIANT contains...
2
by: Heike | last post by:
Hello everybody, I have a Problem with C Sharp. I have to use external functions in DLLs. This Functions are written in Visual C++ 6 like this: int (__stdcall *GetGlobalValue) (VARIANT Appl,...
11
by: MLH | last post by:
The following procedures found at http://ffdba.com/downloads/Send_Mail_With_Outlook_Express.htm are meant to work together in harmony to effect eMail sends via OE. The last procedure (FN SplitB)...
1
by: morten | last post by:
When i compile this code in VC71 or VC80 i get the following errors: The code is copy/paste from the boost.org tutorial. Please help! error C2039: 'begin' : is not a member of...
1
by: captainc | last post by:
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...
4
by: jainchar | last post by:
hello I am creating a VARIANT that stores a integer value of variable but variable is not initialize.In my code the variable are "r" and"c" where r and c are the value of row and column of a table.I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.