Navigation Menu

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
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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