473,847 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "
--------------------------------------------------------------------------
#SimpleCOMServe r.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.Uti lities"

# NEVER copy the following ID!
# Use "print pythoncom.Creat eGuid( )" 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__=='__ma in_ _':
print "Registerin g COM server..."
import win32com.server .register
win32com.server .register.UseCo mmandLine(Pytho nUtilities)
--------------------------------------------------------------------------
Does anybody have experiences in this ?

Any help/hints are very welcome.

Alexander
Jul 18 '05 #1
2 1698
Alexander Eisenhuth <ne******@staco m-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 "
--------------------------------------------------------------------------
#SimpleCOMServe r.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.Uti lities"

# NEVER copy the following ID!
# Use "print pythoncom.Creat eGuid( )" 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__=='__ma in_ _':
print "Registerin g COM server..."
import win32com.server .register
win32com.server .register.UseCo mmandLine(Pytho nUtilities)
--------------------------------------------------------------------------
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******@staco m-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 "
--------------------------------------------------------------------------
#SimpleCOMServ er.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.Uti lities"

# NEVER copy the following ID!
# Use "print pythoncom.Creat eGuid( )" 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__=='__ma in_ _':
print "Registerin g COM server..."
import win32com.server .register
win32com.server .register.UseCo mmandLine(Pytho nUtilities)
--------------------------------------------------------------------------

--
- 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
2863
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 be loaded, which function to be called, and what are the parameters to call the function. Thank you very much!
11
1699
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 if start is greater than end, and direction == true, then the range has reverse direction. If direction == false, the starting point is always less than the end point. To make getting the intersection of two ranges easier, for example, I also...
7
5023
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 implement or implemented in a different naming convention. Could someone please help me or show me another method of doing encryption under Win32? TIA
6
2129
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 Complete Reference. I think I can now follow a normal C++ program but when it comes to Win32 most books I have seen does not explain anything on the structuures or types being used. For Eg what type is LPPROFILEINFO in the below eg. BOOL...
6
1563
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# talks to the managed C++ class. Lots of work. Is this simplified in C++/CLI? Any sample code anywhere?
8
1770
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 to be simple, right? I had thought that the new C++/CLI syntax was supposed to allow mixing of managed/unmanaged in the same class but I'm running into quite a few snags. I'm sure the problems are commonplace, so rather than listing tons of
0
3075
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 method to grab the content of the Edit window. A DialogBox Class window acts as parent to a #32770 child. The #32770 child has an Edit child of its own. The entire dialog is not a standard msgbox; instead, the dialog displays a list of...
1
1514
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 Active_Directory(very easy to use).but it read only AD. So i have been try to install python-ldap on a win32/python2.4 install.But each time i try ------------------------ setup.py build ------------------------
0
2964
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 = "select * from " . $table_name . " ORDER BY stateID ASC"; $result = mysql_query($query, $connection) or die("Could not complete database query"); $num = mysql_num_rows($result); if ($num != 0) {
0
9889
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10988
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10652
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10712
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5723
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4536
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4126
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.