Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

Ctypes module - looking for a way to dynamically call export

 
Jump to:  
 
Guest
PostPosted: Tue Aug 26, 2008 8:42 am    Post subject: Ctypes module - looking for a way to dynamically call export
       
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

Please help

Regards,
Rajat
 

 
Gabriel Genellina
PostPosted: Wed Aug 27, 2008 2:20 am    Post subject: Re: Ctypes module - looking for a way to dynamically call ex
       
En Tue, 26 Aug 2008 07:42:50 -0300, <dudeja.rajat@gmail.com> escribi�:

Quote:
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
 

 
Guest
PostPosted: Thu Aug 28, 2008 5:13 am    Post subject: Re: Ctypes module - looking for a way to dynamically call ex
       
On Wed, Aug 27, 2008 at 5:20 AM, Gabriel Genellina
<gagsl-py2@yahoo.com.ar> wrote:
Quote:
En Tue, 26 Aug 2008 07:42:50 -0300, <dudeja.rajat@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

--
LINK

Hi Gabriel,

Thanks for the help. That solved my problem.

--
Regards,
Rajat
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Odzyskiwanie danych odżywki szkoła policealna gdańsk Bielizna męska Fotka