Re: calling ' extern "C" int __declspec(dllexport) ' declared functions?
Mark McMahon <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <36FA17CA56D6A84D9E422A359CB4F047709629BFEB@ADSK-NAMSG-02.MGDADSK.autodesk.com> |
Hi Ray, > -----Original Message----- > From: RayS [mailto:[email protected]] > Sent: Friday, August 13, 2010 12:24 PM > To: Mark McMahon; [email protected] > Subject: RE: [ctypes-users] calling ' extern "C" int __declspec(dllexport) ' declared functions? > > At 06:51 PM 8/12/2010, Mark McMahon wrote: > ># can you get a reference the DLL > >dll = ctypes.windll.YOURDLLNAME > > yes, it also wasn't immediately obvious that it was a cdecl (which I > used with partial sucess), not a windll > yes - cdl or windll - if one works - use it:) > >Can you get references to the functions... > >SetBlockSize = dll.SetBlockSize #using SetBlockSize is easier as > >the argument is a plain int > > > >ret = SetBlockSize = SetBlockSize(123) > > it returns zero (apparently OK, by the .h file comment) So you can see the function, and you can evey call some of them :) > > ># does ret have the return code for success (or expected return value?) > > > >For GetBlockSize - you will need to read the doc and see what to do > >with pointer/reference values :) (but usually ctypes.byref(var) or > >ctypes.pointer(var) are what you need). > > I tried both byref and pointer, but both returned -1; I'll be talking > to the hardware maker tomorrow are you doing something like the following val = ctypes.c_int() dll.GetBlockSize(ctypes.byref(val)) or dll.GetBlockSize(ctypes.pointer(val)) Because the value will be modified - you need to create it separately first > > Do you write Python code for AutoCAD? I don't work on AutoCAD - but I use Python for automation tasks. > > Thanks, > Ray Hope that helps, Mark > ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev