The code defintions are:
- Code: Select all
'USBUIRT infrared controller (only the needed functions)
Public Declare Function UUIRTOpen Lib "uuirtdrv.dll" () As Long
Public Declare Function UUIRTClose Lib "uuirtdrv.dll" (ByVal hHandle As Long) As Long
Public Declare Function UUIRTTransmitIR Lib "uuirtdrv.dll" ( _
ByVal hHandle As Long, _
ByVal sIRCode As String, _
ByVal uCodeFormat As Long, _
ByVal uRepeatCount As Long, _
ByVal uInactivityWaitTime As Long, _
ByVal hEvent As IntPtr, _
ByVal reserved0 As IntPtr, _
ByVal reserved1 As IntPtr) As Boolean
' Global Variables:
Public IRDriverHandle As Long 'hold USB-UIRT driver handle
Public IRCode As String 'IR transmission code
Public IRCodeFormat As Long 'IR transmission format
and the function I use looks like:
- Code: Select all
Public Function TransmitIR(ByVal IRCode As String, ByVal IRCodeFormat As Long) As Boolean
'Transmit IRCode using IRCodeFormat. Returns True if successful, False if not.
Dim res As Boolean
If IRDriverHandle <> 0 Then 'USB-UIRT is open. Transmit IR
res = UUIRTTransmitIR(IRDriverHandle, IRCode.ToCharArray, IRCodeFormat, 1, 0, 0, 0, 0) 'attempt to transmit. res holds result
If res = False Then
Return False 'Failed - couldn't transmit
Else
Return True 'Succeeded
End If
Else
Return False 'Failed - no driver handle
End If
End Function
The error I'm getting on the UUIRTTransmitIR line is:
A call to PInvoke function 'Cinematics2!Cinematics2.ModuleIR::UUIRTTransmitIR' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Which I gathered is a result of probably a mismatch in the type of the arguments - but I can't figure what's wrong.
Any help would be greatly appreciated.