WindowsXP / CTypes Module - unable to access function in a dll

Discussion in 'Python' started by dudeja.rajat@gmail.com, Aug 19, 2008.

  1. Guest

    Hi,

    I'm using the CTYPES module of python to load a dll. My dll contains a
    Get_Version function as:
    long __stdcall af1xEvdoRDll_GetVersion(long version[4]);

    This function accepts a long array of 4 elements.

    Following is the python code I've written:

    from ctypes import *
    abc = windll.af1xEvdoRDll
    GetVersion = abc.af1xEvdoRDll_GetVersion
    print GetVersion
    versionArr = c_long * 4 #array of 4 longs
    version = versionArr(0, 0, 0, 0) # initializing all elements to 0
    GetVersion(version) #calling dll function
    print version

    I'm getting the following output:
    <_FuncPtr object at 0x00A1EB70>
    <__main__.c_long_Array_4 object at 0x00A86300>

    But I'm not getting the desired output which I expect as : 2.1.5.0


    Please suggest what am I missig?
     
    , Aug 19, 2008
    #1
    1. Advertisements

  2. wrote:

    > Hi,
    >
    > I'm using the CTYPES module of python to load a dll. My dll contains a
    > Get_Version function as:
    > long __stdcall af1xEvdoRDll_GetVersion(long version[4]);
    >
    > This function accepts a long array of 4 elements.
    >
    > Following is the python code I've written:
    >
    > from ctypes import *
    > abc = windll.af1xEvdoRDll
    > GetVersion = abc.af1xEvdoRDll_GetVersion
    > print GetVersion
    > versionArr = c_long * 4 #array of 4 longs
    > version = versionArr(0, 0, 0, 0) # initializing all elements to 0
    > GetVersion(version) #calling dll function
    > print version
    >
    > I'm getting the following output:
    > <_FuncPtr object at 0x00A1EB70>
    > <__main__.c_long_Array_4 object at 0x00A86300>
    >
    > But I'm not getting the desired output which I expect as : 2.1.5.0
    >
    >
    > Please suggest what am I missig?


    Don't print the object, print it's contents:

    for i in xrange(4):
    print version

    Might be that you can iterate over the array directly, not sure right now.

    Diez
     
    Diez B. Roggisch, Aug 19, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NGM
    Replies:
    0
    Views:
    2,597
  2. Roman Yakovenko
    Replies:
    0
    Views:
    409
    Roman Yakovenko
    Apr 14, 2004
  3. Daniel Watrous

    python - dll access (ctypes or swig)

    Daniel Watrous, Apr 17, 2007, in forum: Python
    Replies:
    9
    Views:
    594
    Alex Martelli
    Apr 19, 2007
  4. Replies:
    0
    Views:
    677
  5. Massi

    Ctypes debug of dll function

    Massi, Feb 21, 2009, in forum: Python
    Replies:
    0
    Views:
    386
    Massi
    Feb 21, 2009
  6. ryniek90
    Replies:
    1
    Views:
    667
    Simon Forman
    Aug 21, 2009
  7. Heinrich Piard

    ruby on WindowsXP can't load module wx

    Heinrich Piard, Nov 14, 2008, in forum: Ruby
    Replies:
    2
    Views:
    382
    Alex Fenton
    Nov 14, 2008
  8. Replies:
    10
    Views:
    222
Loading...