use of calldll
Piero
picodello at yahoo.it
Fri Apr 19 07:36:08 EDT 2002
I use the very good calldll module to interface to Windows DLL.
Now I have a problem with this type of function 'C 'prototype :
BOOL ReadOPCItem(HANDLE hConnect,HANDLE hGroup,HANDLE hItem,VARIANT
*pVar,FILETIME * pTimeStamp, DWORD quality)
I make this Python routine :
def ReadOPCItem(self,hGroup,hItem):
#~ ' May be used by an application to read the current value of an
item.
#~ ' Is only valid if EnableDLLBuffering has been set to TRUE when
the
#~ ' connection was established.
#~ Public Type FileTime
#~ dwLowDateTime As Long
#~ dwHighDateTime As Long
#~ End Type
#~ Declare Function ReadOPCItem Lib "WTClient" Alias
"_ReadOPCItem at 24" (ByVal hConnect As Long, ByVal hGroup As Long, ByVal
hItem As Long, Var As Variant, pTimeStamp As FileTime, Quality As
Long) As Long
ReadOPCItem =calldll.get_proc_address(self.opcclient,"_ReadOPCItem at 24")
var_buf = calldll.membuf(8)
filetime_buf = calldll.membuf(8)
quality_buf = calldll.membuf(4)
stato = calldll.call_foreign_function (ReadOPCItem,'llllll', 'i',
(self.handle,hGroup,hItem,var_buf.address(),filetime_buf.address(),quality_buf.address()))
quality = struct.unpack ('l', quality_buf.read())
value = struct.unpack ('bbbbbbb', var_buf.read())
filetime = struct.unpack ('ll', filetime_buf.read())
return stato,value,quality,filetime
Something can help on using VARIANT type in Python and CALLDLL
Thanks
Piero Dell'OSte
More information about the Python-list
mailing list