472,363 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,363 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 3411
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.