Skip to content

Instantly share code, notes, and snippets.

@pfmoore
Created January 7, 2015 15:49
Show Gist options
  • Save pfmoore/db6f7718885a49e8918f to your computer and use it in GitHub Desktop.
Save pfmoore/db6f7718885a49e8918f to your computer and use it in GitHub Desktop.
from cffi import FFI
ffi = FFI()
ffi.cdef('''
HANDLE FindFirstVolume(LPTSTR lpszVolumeName, DWORD cchBufferLength);
BOOL FindVolumeClose(HANDLE hFindVolume);
''')
lib = ffi.verify('''
/* Note - need UNICODE here as ffi won't auto-detect if we need it */
#define UNICODE
#include <windows.h>
''', libraries=["kernel32"])
LEN = 10000
buf = ffi.new("TCHAR[]", LEN)
h = FindFirstVolume(buf, LEN)
print(ffi.string(buf))
FindVolumeClose(h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment