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:
[sourcecode language=”python”]
from ctypes import *
from ctypes import *
libc = windll.LoadLibrary(‘C:\\Windows\\kernel32.dll”)
x = libc.GetModuleHandleA ()
print x #Prints the object
del libc #Deletes the handle
[/sourcecode]
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!
can you show us please how would i use one of kernel32.dll functions, like GetFileAttributes ?
Thanks
You would need win32api for this
import win32api, win32con
myFile = r’C:\foo.txt’
fileAtt = win32api.GetFileAttributes(myFile)