Re: [ctypes-users] calling ' extern "C" int __declspec(dllexport) ' declared functions?
Brought to you by:
theller
From: Mark M. <mar...@au...> - 2010-08-13 11:30:57
|
Hi Ray, > -----Original Message----- > From: RayS [mailto:ra...@bl...] > Sent: Friday, August 13, 2010 12:24 PM > To: Mark McMahon; cty...@li... > 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 > |