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?
Python provides you one.

Code snippet:
[sourcecode language=”python”]
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!

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.