Python: Working with Dynamic Link Library (dll)


Problem Statement:
What if you get a DLL file and you want to quickly test some of the exported APIs? Any ideas?
Solution:
Python provides you one.

Code snippet:
from ctypes import *

libc = windll.LoadLibrary('C:\\Windows\\kernel32.dll'')

x = libc.GetModuleHandleA ()

print x   #Prints the object

del libc  #Deletes the handle

In this code: we load kernel32.dll file and pass None argument to GetModuleHandleA function of the Dll.
Similarly you could customize this small code for your use.
Simple and quick!
Enjoy! Please do comment!
Advertisements

2 thoughts on “Python: Working with Dynamic Link Library (dll)

  1. You would need win32api for this

    import win32api, win32con
    myFile = r’C:\foo.txt’
    fileAtt = win32api.GetFileAttributes(myFile)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s