开发者

win32 API calls from cython

开发者 https://www.devze.com 2023-03-19 09:08 出处:网络
Hi i\'m trying to call the CreateFileA win32 function from a pyx file (cython file)(windows.h is already included from the pxd file), but it doesn\'t work ... does anyone ever tried to do so... needs

Hi i'm trying to call the CreateFileA win32 function from a pyx file (cython file)(windows.h is already included from the pxd file), but it doesn't work ... does anyone ever tried to do so... needs help please

More informations: i got no errors when compiling with Mingw, but at the execution i get -1 as return value..

illustration :

myfile.pxd

cdef extern from "ftd2xx.h":

   stuff....

   # CreateFileA declaration

   HANDLE **CreateFileA***(LPCSTR lpFileName, DWORD dwDesiredAccess, 
       DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, 
       DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, 
       HANDLE hTemplateFile)*

myfile.pyx

cimport myfile.pxd

def somefuction()
HA开发者_JAVA百科NDLE a = myfile.**CreateFileA**(......)

at the execution i get -1


Negative 1 (-1 return) means there were multiple errors. It's possible that you are including from the wrong place.

Anyway, my python experience tells me that you can use win32all, from Mark Hammond, to call the win32api. That should solve all your problems.

If it doesn't:

I snooped around Stack Overflow and found lots of people had similar problems. Here are some things you can try:

mingw_setup_args={'options': {'build_ext': {'compiler': 'mingw32'}}} import pyximport; pyximport.install(setup_args=mingw_setup_args)

Browse to: c:\Python2x\Lib\distutils\distutils.cfg:

[build]
compiler = mingw32

[build_ext]
compiler = mingw32

I encourage you to branch out. If you notice the right sidebar, "related" div on this page, you'll see that there are many people who have asked similar questions. I hope it gets you started. Alternatively, I recommend you look for a better compiler--something that will give you a full error report. Post the error report here. Try to be as precise as possible if there's anything you want to exclude, so that you remove as little helpful data as possible. You can definitely find a solution if one exists, provided you find a complete error message.

I'm almost certain that a full error report exists somewhere, and you just don't know where to look. I found out very early in my programming career that this is always the case when it seems there's "no error" to a programmer: they're looking in the wrong place. So, you should figure out where to look for a complete error report.

0

精彩评论

暂无评论...
验证码 换一张
取 消