COM :: VARIANT -eek

M

Matt Smith

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
 
M

Mark Hammond

Matt said:
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.
 
M

Matt Smith

Mark Hammond said:
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 ?
 
M

Mark Hammond

Matt said:
Mark Hammond <[email protected]> wrote in message news:<[email protected]>...
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
 
M

Matt Smith

Mark Hammond said:
These type libraries are in the registry. You may be able to pass the
filename on the commandline to makepy.


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.
 
M

Matt Smith

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top