Domanda

Attualmente sto provando a fare qualche introspezione su una DLL con Python. Voglio creare automaticamente un'interfaccia di test grafica basata su una DLL.

Posso caricare abbastanza facilmente la mia DLL in Python e chiamo alcune funzioni. Il problema principale è se chiamo " dir " sull'oggetto senza chiamare alcun metodo, ho come risultato

>>> dir(myLib)
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattr__', '__getattribute__', '__getitem__', '__hash__', '__i
nit__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__s
etattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_fl
ags_', '_func_restype_', '_handle', '_name']

e quando chiamo manualmente una funzione (come " Read_Version ") ho come risultato la funzione dir

>>> dir(myLib)
['Read_Version', '_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattr__', '__getattribute__', '__getitem__', '__hash__', '__i
nit__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__s
etattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_fl
ags_', '_func_restype_', '_handle', '_name']

Sembra che l'introspezione funzioni solo sulla funzione che ho già chiamato e questo non è davvero "utile" ;).

Hai un'altra idea per recuperare le funzioni che si trovano in una DLL? (ovviamente in pitone)

Sto usando Python 2.6 in Windows.

È stato utile?

Soluzione

Per quanto ne so, non esiste un modo semplice per farlo. Devi usare uno strumento esterno (es. link / dump / exports ) o usare un parser PE / DLL (es. pefile ).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top