Bluesoleil Bluetooth API - Bad DLL calling convention

E

Eile

Hello,

I'm trying to access the Bluesoleil Bluetooth API from VBA.
But at all functions with parameters I get a Run-time error '49' Bad
DLL calling convention.
Am I doing something wrong?
Please help!

Peter

This is my code:

Global Const EVENT_CONNECTION_STATUS = 3

Public Declare Function BT_InitializeLibrary Lib "btfunc.dll" () As
Boolean
Public Declare Sub BT_UninitializeLibrary Lib "btfunc.dll" ()
Public Declare Function BT_RegisterCallback Lib "btfunc.dll" (ByVal
ucEvent As Byte, pfnCbkFun As Long) As Long
Public Declare Function BT_IsBlueSoleilStarted Lib "btfunc.dll" (ByVal
dwSeconds As Long) As Long
Public Declare Function BT_IsBluetoothReady Lib "btfunc.dll" (ByVal
dwSeconds As Long) As Long
Public Declare Function BT_InquireDevices Lib "btfunc.dll" (ByVal
ucInqMode As Byte, ByVal ucInqTimeLen As Byte, ByVal lpDevsListLength
As Long, pDevsList() As BLUETOOTH_DEVICE_INFO) As Long

Public Type BLUETOOTH_DEVICE_INFO
dwSize As Long
address As String * 6
classOfDevice As String * 3
szName As String * 64
bPaired As Boolean
End Type

Public Sub BTConnectionEvent(ByVal wServiceClass As Integer, ByVal
lpBdAddr As String, ByVal ucStatus As Byte, dwConnetionHandle As Long)
MsgBox wServiceClass
End Sub

Sub BT_Start()
Dim bdilen As Long
Dim bdi(5) As BLUETOOTH_DEVICE_INFO
Dim bdi1 As BLUETOOTH_DEVICE_INFO

If BT_InitializeLibrary Then ' Is working
If BT_IsBlueSoleilStarted(5) Then ' Run-time error '49'
MsgBox BT_RegisterCallback(EVENT_CONNECTION_STATUS,
AddressOf BTConnectionEvent) Run-time error '49'
bdilen = Len(bdi1) * 5
MsgBox BT_InquireDevices(2, 5, bdilen, bdi) Run-time error
'49'
End If
End If
BT_UninitializeLibrary ' Is working
End Sub

This is the declaration in C:

typedef struct _BLUETOOTH_DEVICE_INFO {
DWORD dwSize;
BYTE address[DEVICE_ADDRESS_LENGTH];
BYTE classOfDevice[DEVICE_CLASS_LENGTH];
CHAR szName[MAX_DEVICE_NAME_LENGTH];
BOOL bPaired;
} BLUETOOTH_DEVICE_INFO, *PBLUETOOTH_DEVICE_INFO;

BOOL BT_InitializeLibrary();
void BT_UninitializeLibrary ();
BOOL BT_IsBlueSoleilStarted(/* [in] */ DWORD dwSeconds );
BOOL BT_IsBluetoothReady (/* [in] */ DWORD dwSeconds );
DWORD BT_RegisterCallback(
/* [in] */ UCHAR ucEvent,
/* [in] */ LPVOID pfnCbkFun
);
typedef void (*PCALLBACK_CONNECTION_STATE_CHANGED)
(WORD wServiceClass, BYTE* lpBdAddr, UCHAR ucStatus, DWROD
dwConnetionHandle);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top