• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from cffi import FFI
2
3ffi = FFI()
4ffi.cdef('''
5    typedef void * HANDLE;
6    typedef HANDLE HWND;
7    typedef int BOOL;
8    typedef unsigned int UINT;
9    typedef int SIZE_T;
10    typedef char * LPTSTR;
11    typedef HANDLE HGLOBAL;
12    typedef HANDLE LPVOID;
13
14    HWND GetConsoleWindow(void);
15
16    LPVOID GlobalLock( HGLOBAL hMem );
17    BOOL GlobalUnlock( HGLOBAL hMem );
18    HGLOBAL GlobalAlloc(UINT uFlags, SIZE_T dwBytes);
19
20    BOOL  OpenClipboard(HWND hWndNewOwner);
21    BOOL  CloseClipboard(void);
22    BOOL  EmptyClipboard(void);
23    HANDLE  SetClipboardData(UINT uFormat, HANDLE hMem);
24
25    #define CF_TEXT ...
26    #define GMEM_MOVEABLE ...
27
28    void * memcpy(void * s1, void * s2, int n);
29    ''')
30
31ffi.set_source('_winclipboard_cffi', '''
32    #include <windows.h>
33''', libraries=["user32"])
34
35if __name__ == '__main__':
36    ffi.compile()
37