Hi All,

I am trying to generate a DLL from a python script that can be accessed from a 
variety other programming platforms.

I am generating the python-based COM DLL using a distutils setup script that is 
called using py2exe.

The DLL is successfully generated and I can register it using regsvr32, but now 
I am not sure how to access the function within the dll.  This is a test 
scenario but ideally I will have multiple functions in my python script that 
will need to be called and to which I will need to pass arguments.

In order to test this process I created a simple python script:



testscript.py

/////////////////////////

class testscript:

    def tryit(a,b):
        alexis = a + b
        return alexis
/////////////////////////



I then ran the following setup script from command line>> setup.py py2exe

setup.py

/////////////////////////

from distutils.core import setup
import py2exe
import sys
import comtypes
import comtypes.client

class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the version info resources (Properties -- Version)
        self.version = "0.0.1"
        self.company_name = "my company"
        self.copyright = "(c) 2006, my company"
        self.name = "my com server name"

my_com_server_target = Target(
    description = "my com server",
    # use module name for ctypes.com dll server
    modules = ["testscript"],
    # we only want the inproc (dll) server
    create_exe = False

    create_dll = True
    )

setup(
    name="my_com_server",
    # the following two parameters embed support files within dll file
    options={"py2exe": {"bundle_files": 1, }},
    zipfile=None,
    version="0.0.1",
    description="my com server",
    # author, maintainer, contact go here:
    author="First Last",
    
author_email="some_name@some_company.com<https://ch1prd0102.outlook.com/owa/redir.aspx?C=uQeS3p99F02hlyLkjgUCWD_IvKYh_M4Ifcon90VNuxNzuAci5VhvJPb0gg_hrvvyb-5jqALjBEM.&URL=mailto%3asome_name%40some_company.com>",
    ctypes_com_server=[my_com_server_target]
    )
//////////////////////////////////////



>From command line I run>> regsvr32 testscript.dll

The dll is successfully registered.

I am assuming that I now have a COM DLL that I can test in python using 
win32com, but I am not sure how to go about doing this.

Any help would be greatly appreciated!
Thanks,

Alexis


[cid:image001.gif@01CD2915.42AE8CC0]





This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

<<inline: image001.gif>>

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to