Actually Running a function from a DLL

Peter Olsen olsen at umbc.edu
Tue Apr 11 20:02:41 EDT 2000


I'm writing to ask a question about calling a dll file with the
windll/calldll package.

First, thanks to Mark Hammond, Neil Hodgson, and Peter Desaulniers for
their responses and help with my previous question.

I have a DLL file, ETIEncr.dll, with documentation purporting to show
it contains a function GetVersion() (of no arguments) which returns
the version number as a string, e.g. "1.1". I want to call this
function and several others from the dll using windll/calldll.

After putting windll.py and calldll.pyd in the directory
..\Python\Lib\Plat-Win (a directory which is already in sys.path), I
have tried to execute GetVersion() in the PythonWin environment
following the commented directions in windll.py.

This is what happens

>>> import windll
>>> from windll import *
>>> etie = module("ETIEncr")
>>> etie
<win32 module 'ETIEncr' (0 functions)>
>>> etie.GetVersion()
Traceback (innermost last)
  File "<interactive input>", line 0 in ?
  File "dynwin\windll.py", line 91 in __getattr__
    raise AttributeError 'GetProcAddress failed for %s' % name
AttributeError: GetProcAddress failed for GetVersion
>>>

I think I've matched the calls exactly with those in the kernel32.Beep
example in windll.py.  There is one possible difference between that
example and my call here.  The PythonWin COMbrowser shows an
"intermediate layer" between the ETIEncr library and the GetVersion()
function.  The hierarchy is

ETIEncy
 |
 +--Type Library
       |
       +--IEtiEncrypt - Dispatch
             |
             +--GetVersion - Function

The COMBrowser shows these details for GetVersion:

Dispatch ID = 3
Return Type = 'String'
Function Kind = 'Dispatch'
Invoke Kind = 'Function'
Number Optional Parameters = 0


If possible, I would appreciate it if you would send any responses to
pcolsen at draper.com.  Company policy makes it hard to read news.

Thanks!

Peter
-- 
   Peter Olsen, PE,            n2ell          engineer at draper.com
     P.O. Box 410, Simpsonville, MD 21150-0410 USA, 410-997-8584
   "Engineering is the art of applying a professional knowledge of
mathematics and the physical sciences to improve the quality of life."



More information about the Python-list mailing list