473,387 Members | 1,464 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,387 software developers and data experts.

win32 COM and data types / direction

Hello everybody,

i wonder how the win32 COM extension handles different C-int types
(short, int, long). Another question for me is weather the
"out-direction" of parameter is supported "out of the box" ?

To clarify look at the methode "FunWithTwoInts"
--------------------------------------------------------------------------
#SimpleCOMServer.py - A sample COM server - almost as small as they come!
#
# We expose a single method in a Python COM object
class PythonUtilities:
_public_methods_ = [ 'FunWithTwoInts' ]
_reg_progid_ = "PythonDemo.Utilities"

# NEVER copy the following ID!
# Use "print pythoncom.CreateGuid( )" to make a new one
_reg_clsid_ = "{40CEA5F8-4D4C-4655-BD8B-0E7B6A26B556}"

def FunWithTwoInts(self, inShort, inInt, outSum):
print "got as short:%d as int:%d sum:%d" % (inShort, inInt, outSum)
outSum = inShort + inInt

# Add code so that when this script is run by
# Python.exe, it self-registers
if __name__=='__main_ _':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtil ities)
--------------------------------------------------------------------------
Does anybody have experiences in this ?

Any help/hints are very welcome.

Alexander
Jul 18 '05 #1
2 1676
Alexander Eisenhuth <ne******@stacom-software.de> writes:
Hello everybody,

i wonder how the win32 COM extension handles different C-int types
(short, int, long). Another question for me is weather the
"out-direction" of parameter is supported "out of the box" ?

To clarify look at the methode "FunWithTwoInts"
--------------------------------------------------------------------------
#SimpleCOMServer.py - A sample COM server - almost as small as they come!
#
# We expose a single method in a Python COM object
class PythonUtilities:
_public_methods_ = [ 'FunWithTwoInts' ]
_reg_progid_ = "PythonDemo.Utilities"

# NEVER copy the following ID!
# Use "print pythoncom.CreateGuid( )" to make a new one
_reg_clsid_ = "{40CEA5F8-4D4C-4655-BD8B-0E7B6A26B556}"

def FunWithTwoInts(self, inShort, inInt, outSum):
print "got as short:%d as int:%d sum:%d" % (inShort, inInt, outSum)
outSum = inShort + inInt

# Add code so that when this script is run by
# Python.exe, it self-registers
if __name__=='__main_ _':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtil ities)
--------------------------------------------------------------------------
Does anybody have experiences in this ?


Since there is no type library, the client code has to guess. And it
will pass the server whatever the client calls with. That could even be
a string or anything else - but why not try it out?

*IF* there is a type library that the server implements, you will get
and return what it describes.

Thomas
Jul 18 '05 #2
Alexander Eisenhuth <ne******@stacom-software.de> wrote:

Hello everybody,

i wonder how the win32 COM extension handles different C-int types
(short, int, long).
All of those types are passed on the stack as 32-bit dwords. No problem.
Another question for me is weather the
"out-direction" of parameter is supported "out of the box" ?
Yes, but you have to make them outputs from your function. Remember that
assigning to a parameter in Python does not change the parameter from the
caller's point of view:

def FunWithTwoInts( self, inShort, inInt ):
print "got as short:% as int%d" % (inShort, inInt)
return inShort + inInt

If you have multiple OUT parameters, you return a tuple of values.
To clarify look at the methode "FunWithTwoInts"
--------------------------------------------------------------------------
#SimpleCOMServer.py - A sample COM server - almost as small as they come!
#
# We expose a single method in a Python COM object
class PythonUtilities:
_public_methods_ = [ 'FunWithTwoInts' ]
_reg_progid_ = "PythonDemo.Utilities"

# NEVER copy the following ID!
# Use "print pythoncom.CreateGuid( )" to make a new one
_reg_clsid_ = "{40CEA5F8-4D4C-4655-BD8B-0E7B6A26B556}"

def FunWithTwoInts(self, inShort, inInt, outSum):
print "got as short:%d as int:%d sum:%d" % (inShort, inInt, outSum)
outSum = inShort + inInt

# Add code so that when this script is run by
# Python.exe, it self-registers
if __name__=='__main_ _':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(PythonUtil ities)
--------------------------------------------------------------------------

--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #3

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

Similar topics

4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
11
by: Bob Hairgrove | last post by:
The following class contains start and end points of a range of values. The range can have a direction which is implied from the relative order of start and end, or it can be without direction. IOW...
7
by: Kenjis Kaan | last post by:
I would like to use the crypt function in a Win32 (ie. C program using Visual C++ 6.0 compiler). I wrote a little program to see if it will link but it didn't. So I guess maybe the function isn't...
6
by: Rajesh | last post by:
I am a System Administrator and do some programming (Admin Utlities) in VB6 & C#.net. I am interested in Win32 and thought of learning C++ (as it is a pre-requsite) and read 13 chapters from C++.Net...
6
by: _R | last post by:
I've had to write a lot of code to interface C# to older Win32 DLLs. Basically, an unmanaged C++ class talks directly to the Win32 DLL. A managed C++ class encloses the unmanaged C++ class. C#...
8
by: _iycrd | last post by:
Specifically I need to wrap an older Win32 DLL in a managed class. I had this running with VS2003's Managed Extensions, though it required two separate classes. With C++/CLI this was supposed...
0
by: artofsuntzu | last post by:
I am trying to use Win32 API in Visual Basic 6.0 to get the text from a third party program that is using an Edit Control Window within a #32770 DialogBox. But I am unable to find any SendMessage...
1
by: rcmn | last post by:
i'm running around in circle trying to to use python/ldap/ on win32(WinXP). I want to write a script that read SQL data(no pbm) and insert member in a AD group(pbm).I used the module...
0
by: Hags007 | last post by:
I have a XML file I am working with. This file has been created by hand and I now need to develop a PHP script that will create it in the same format. Here is what I have thus far: $query =...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.