calldll: given a longint (=pointer) - howdoi access the data?

Martin Bless m.bless at gmx.de
Tue Jun 19 18:40:53 EDT 2001


The code below is a complete and working example (victory!!! I'm
making progress!!!) of how to call the german "KlickTel" cdrom (all
german telephone numbers and addresses) from Python using calldll.pyd
and windll.py (To be able to do this you additionally have to buy and
own the necessary ktdev32.dll, which is 499,-DM :-(

*** One problem:
The dll calls the callback function with a pointer to a 860-byte data
structure.

*** How do I turn this longint (being a pointer) into a Python data
structure (let's say string)?

In other words, I need the opposite of what
calldll.membuf(860).address() does. How can I do this?

Hhm, hope I made my problem clear!

Can't wait for someone helping me to make the final little step, now
that I've gotten that much far!

Martin



A few lines may be wrapped:

"""Trying to call and use ktdev32.dll from Python

callKtel.py, mb, 2001-06-19
"""
import windll, gencb

#KtelDLLRec = calldll.membuf(860)

def callback( PKtelDLLRec):
    print "Hi, here's the callback function!"
    print "PKtelDLLRec:", hex(PKtelDLLRec), PKtelDLLRec
    return 0

## Sample output:
## Hi, here's the callback function!
## PKtelDLLRec: 0x63f140 6549824


cb = gencb.generated_callback ('l', callback)
 
kt = windll.module('ktdev32')
print "kt:", kt
print "Version:", kt.KTVersion()
ktPath = windll.cstring(r'd:\ProgrammeC\klickTel\klickTel April
2001',remember=1).address()

ktCaption = windll.cstring('ktdev32 called from
Python',remember=1).address()

result = kt.klickTelInit( ktPath, cb.address, ktCaption)

adLastName = windll.cstring('b',remember=1).address()
print "SetLastName:", kt.SetLastName( adLastName)

adFirstName = windll.cstring('m',remember=1).address()
print "SetFirstName:", kt.SetFirstName( adFirstName)

adPostcode = windll.cstring('4',remember=1).address()
print "SetPostcode:", kt.SetPostcode( adPostcode)

adStreet = windll.cstring('v',remember=1).address()
print "SetStreet:", kt.SetStreet( adStreet)

adTown = windll.cstring('m',remember=1).address()
print "SetTown:", kt.SetTown( adTown)

result = kt.SearchAssistant()

input = 'x'
while not input:
    print "result:", result
    input = raw_input()

print "klickTelDone:", kt.klickTelDone()
print "unload:", kt.unload()
        



More information about the Python-list mailing list