Ctypes module - looking for a way to dynamically call exported function from a set of dlls

dudeja.rajat at gmail.com dudeja.rajat at gmail.com
Thu Aug 28 09:13:15 CEST 2008


On Wed, Aug 27, 2008 at 5:20 AM, Gabriel Genellina
<gagsl-py2 at yahoo.com.ar> wrote:
> En Tue, 26 Aug 2008 07:42:50 -0300, <dudeja.rajat at gmail.com> escribi�:
>
>> Hi,
>>
>> I'm using the ctypes module to load my dlls.
>>
>> I have some 10 dlls the names of those are passed to a fucntion which
>> then loads the passed dll.
>>
>> Now every dll has a getversion function.
>> eg: A.dll, B.dll, C.dll are the dlls
>> and GetVersion functions are as:
>> A_getVersion(), B_getVersion(),
>> C_getVesion()
>>
>>
>>
>> The functionality I'm lookking for is that depending on the dll passed
>> the right getVersion should be passed.
>>
>> I'm able to load the all the dlls passed to the function but I'm not
>> able to call the function names dynamically
>
> Use getattr - same as with any other object.
> Suppose some_dll is your loaded DLL, then:
>
> function = getattr(some_dll, function_name)
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list

Hi Gabriel,

Thanks for the help. That solved my problem.

-- 
Regards,
Rajat


More information about the Python-list mailing list