Skip to content

Instantly share code, notes, and snippets.

@joselitosn
Forked from pfmoore/ffi_ex.py
Last active August 29, 2015 14:25
Show Gist options
  • Save joselitosn/fbdd6f62a913bb9850f4 to your computer and use it in GitHub Desktop.
Save joselitosn/fbdd6f62a913bb9850f4 to your computer and use it in GitHub Desktop.
from cffi import FFI
ffi = FFI()
ffi.set_unicode(True)
ffi.cdef('''
HANDLE FindFirstVolume(LPTSTR lpszVolumeName, DWORD cchBufferLength);
BOOL FindVolumeClose(HANDLE hFindVolume);
''')
lib = ffi.verify('''
#include <windows.h>
''', libraries=["kernel32"])
LEN = 10000
buf = ffi.new("TCHAR[]", LEN)
h = lib.FindFirstVolume(buf, LEN)
print(ffi.string(buf))
lib.FindVolumeClose(h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment