Python Forum
Trying to use ctypes.wintypes.HINSTANCE
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to use ctypes.wintypes.HINSTANCE
#1
I am trying to call a function from a dll(A) that is loaded by another dll(B). (A) has a function exposed getDLL that returns a winapi handle to (B). I cannot for the life of me access functions from (B) via the handle. I either get c_void_p has not method or function... or I get the same for type c_long. I have tried both casting my returned handle as wintypes.hinstance and I have tried by setting the restype.

....
def testFunc(ADLL, CWD):
    import ctypes.wintypes
    ADLL.GetDLL.restype = ctypes.wintypes.HINSTANCE
    cp = c_char_p("{0}{1}".format(CWD, "B.dll"))
    B = A.GetDLL(cp)
    B.SomeFunction() #This fails with c_Long has no method or function ....
    cast(B, ctypes.wintypes.HINSTANCE).SomeFucntion() #This fails with c_void_p has no method or function ....
....
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  using ctypes to use a dll in a python module dauriac 3 291 Mar-06-2024, 04:38 PM
Last Post: dauriac
  Trying to debug segfault in ctypes binding to Fortran bthomas 1 568 Sep-01-2023, 11:26 AM
Last Post: bthomas
  ctypes juliolop 7 1,327 Apr-20-2023, 03:33 PM
Last Post: Larz60+
  Issue while using ctypes in python GiggsB 6 2,688 Mar-27-2022, 03:38 AM
Last Post: GiggsB
  Ctypes and libffi.so.7 luxedo 1 5,982 Oct-23-2021, 09:24 PM
Last Post: DeaD_EyE
  possible ctypes and numpy conflict? herbal_rage 0 3,092 Apr-16-2020, 11:35 AM
Last Post: herbal_rage
  python kernell crash with a ctypes program Jstechg 1 3,451 Nov-24-2018, 02:37 PM
Last Post: Jstechg
  generating ctypes wrapper for a c library? brighteningeyes 9 6,946 Nov-04-2018, 02:31 AM
Last Post: brighteningeyes
  DLL library with ctypes Max20 0 2,881 Aug-19-2018, 11:15 AM
Last Post: Max20
  dll not loading to Ctypes Philbot 1 6,799 Jul-01-2018, 09:55 AM
Last Post: Philbot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020