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 2 1691
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
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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!
|
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...
|
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
|
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...
|
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?
| |
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
|
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...
|
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
------------------------
|
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) {
|
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...
|
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...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |