
Desde ya muchas gracias.
Escrito 17 junio 2011 - 08:42
Escrito 17 junio 2011 - 08:45
Escrito 17 junio 2011 - 09:45
Escrito 17 junio 2011 - 10:56
procedure HolaMundo; external 'archivoDLL.dll'
Escrito 17 junio 2011 - 08:31
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; CheckBox1: TCheckBox; procedure Button1Click(Sender: TObject); private { private declarations } public function BT_InitializeLibrary() : Boolean; stdcall; end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin CheckBox1.Checked:= BT_InitializeLibrary(); end; //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TForm1.BT_InitializeLibrary() : Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; {$R *.lfm} end.
Escrito 17 junio 2011 - 09:35
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) BTN_BT_InitializeLibrary: TButton; btn_BT_UninitializeLibrary: TButton; BTN_BT_IsBlueSoleilStarted: TButton; CB_BT_InitializeLibrary: TCheckBox; CB_BT_IsBlueSoleilStarted: TCheckBox; E_BT_IsBlueSoleilStarted: TEdit; Label1: TLabel; procedure BTN_BT_InitializeLibraryClick(Sender: TObject); procedure BTN_BT_IsBlueSoleilStartedClick(Sender: TObject); procedure btn_BT_UninitializeLibraryClick(Sender: TObject); private { private declarations } public function BT_InitializeLibrary() : Boolean; stdcall; procedure BT_UninitializeLibrary() ; cdecl; function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.BTN_BT_InitializeLibraryClick(Sender: TObject); begin CB_BT_InitializeLibrary.Checked:= BT_InitializeLibrary(); end; procedure TForm1.BTN_BT_IsBlueSoleilStartedClick(Sender: TObject); var secons: DWord; begin // Como paso de str a Dword o de Float a Dword o de lo que sea a DWord // secons:= strtoDWORD (E_BT_IsBlueSoleilStarted.text) // CB_BT_IsBlueSoleilStarted.Checked:= BT_IsBlueSoleilStarted(secons); end; procedure TForm1.btn_BT_UninitializeLibraryClick(Sender: TObject); begin BT_UninitializeLibrary(); end; //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TForm1.BT_InitializeLibrary() : Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; procedure TForm1.BT_UninitializeLibrary(); cdecl; external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TForm1.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; {$R *.lfm} end.
Escrito 17 junio 2011 - 09:38
Escrito 19 junio 2011 - 03:58
unit UBluetooth; {$mode objfpc}{$H+} interface uses Classes, SysUtils; type T_BLUETOOTH_DEVICE_INFO = Record dwSize :DWORD ; address : BYTE; classOfDevice : Byte; szName : char; bPaired: boolean; end; T_BLUETOOTH_DEVICE_INFO_EX = Record dwSize : DWORD; address: BYTE ; classOfDevice : BYTE ; szName :CHAR ; bPaired: Boolean; // ucLmpVersion: UCHAR ; wManuName: WORD ; wLmpSubversion: WORD ; // reserved[16] : BYTE ; wClockOffset: WORD ; bConnected :Boolean ; dwDataRecvBytes: DWORD ; dwDataSentBytes: DWORD ; cSignalStrength : CHAR ; end; T_SPP_CLIENT_PARAM = Record dwSize: DWORD ; // ucComIndex: UCHAR ; end; T_DUN_CLIENT_PARAM = Record dwSize: DWORD; wShortcutFlags: Boolean; bAutoDial: Boolean ; szUserName: CHAR; password: CHAR; dialNumber: CHAR; end; T_OPP_CLIENT_PARAM =Record dwSize: DWORD ; wCmdFlags: WORD ; szObjectPath: CHAR; end; T_SYNC_CLIENT_PARAM = Record dwSize: DWORD ; bShowSyncDlg: Boolean ; // ucSyncType: UCHAR ; end; T_GENERAL_SERVICE_INFO = Record dwSize: DWORD ; dwServiceHandle: DWORD ; wServiceClassUuid16: WORD ; szServiceName: CHAR; end; T_SPPEX_SERVICE_INFO = Record dwSize: DWORD ; dwSDAPRecordHanlde: DWORD ; // serviceClassUuid128: UUID ; szServiceName: CHAR; // ucServiceChannel: UCHAR ; // ucComIndex: UCHAR ; end; T_GENERAL_CONNECT_INFO = Record dwHandle: DWORD ; bIsOutgoing: Boolean ; wServiceClasss: WORD ; remoteBdAddr: BYTE; end; TBluetooth = class(TComponent) private { private declarations } public function BT_InitializeLibrary() : Boolean; stdcall; procedure BT_UninitializeLibrary() ; cdecl; function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; end; implementation //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_InitializeLibrary() : Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; procedure TBluetooth.BT_UninitializeLibrary(); cdecl; external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TBluetooth.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; end.
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, UBluetooth; type { TForm1 } TForm1 = class(TForm) BTN_BT_InitializeLibrary: TButton; btn_BT_UninitializeLibrary: TButton; BTN_BT_IsBlueSoleilStarted: TButton; CB_BT_InitializeLibrary: TCheckBox; CB_BT_IsBlueSoleilStarted: TCheckBox; E_BT_IsBlueSoleilStarted: TEdit; Label1: TLabel; procedure BTN_BT_InitializeLibraryClick(Sender: TObject); procedure BTN_BT_IsBlueSoleilStartedClick(Sender: TObject); procedure btn_BT_UninitializeLibraryClick(Sender: TObject); private { private declarations } public bl : TBluetooth; end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.BTN_BT_InitializeLibraryClick(Sender: TObject); begin CB_BT_InitializeLibrary.Checked:= bl.BT_InitializeLibrary(); end; procedure TForm1.BTN_BT_IsBlueSoleilStartedClick(Sender: TObject); var secons: DWord; begin // Como paso de str a Dword o de Float a Dword o de lo que sea a DWord // secons:= strtoDWORD (E_BT_IsBlueSoleilStarted.text) // CB_BT_IsBlueSoleilStarted.Checked:= BT_IsBlueSoleilStarted(secons); end; procedure TForm1.btn_BT_UninitializeLibraryClick(Sender: TObject); begin bl.BT_UninitializeLibrary(); end; {$R *.lfm} end.
Escrito 20 junio 2011 - 01:52
unit UBluetooth; {$mode objfpc}{$H+} interface uses Classes, SysUtils; type //Recor 1 T_BLUETOOTH_DEVICE_INFO = Record dwSize :DWORD ; address : TByteArray; classOfDevice : TByteArray; szName : Array[0..100] of char; bPaired: boolean; end; //Recor 2 T_BLUETOOTH_DEVICE_INFO_EX = Record dwSize : DWORD; address: TByteArray ; classOfDevice : TByteArray ; szName : Array[0..100] of char; bPaired: Boolean; ucLmpVersion: Byte; //UCHAR ; wManuName: WORD ; wLmpSubversion: WORD ; reserved : Array[0..15] of BYTE ; wClockOffset: WORD ; bConnected :Boolean ; dwDataRecvBytes: DWORD ; dwDataSentBytes: DWORD ; cSignalStrength : CHAR ; end; //Recor 3 T_SPP_CLIENT_PARAM = Record dwSize: DWORD ; ucComIndex: Byte; //UCHAR ; end; //Recor 4 T_DUN_CLIENT_PARAM = Record dwSize: DWORD; wShortcutFlags: Boolean; bAutoDial: Boolean ; szUserName: Array[0..100] of Char; password: Array[0..100] of Char; dialNumber: Array[0..100] of Char; end; //Recor 5 T_OPP_CLIENT_PARAM =Record dwSize: DWORD ; wCmdFlags: WORD ; szObjectPath: Array[0..100] of Char; end; //Recor 6 T_SYNC_CLIENT_PARAM = Record dwSize: DWORD ; bShowSyncDlg: Boolean ; ucSyncType: Byte; //UCHAR ; end; //Recor 7 T_GENERAL_SERVICE_INFO = Record dwSize: DWORD ; dwServiceHandle: DWORD ; wServiceClassUuid16: WORD ; szServiceName: Array[0..100] of Char; end; //Recor 8 T_SPPEX_SERVICE_INFO = Record dwSize: DWORD ; dwSDAPRecordHanlde: DWORD ; serviceClassUuid128: TGuid; //UUID ; szServiceName: Array[0..100] of Char; ucServiceChannel: Byte ; //uchar ucComIndex: Byte ; //uchar end; //Recor 9 T_GENERAL_CONNECT_INFO = Record dwHandle: DWORD ; bIsOutgoing: Boolean ; wServiceClasss: WORD ; remoteBdAddr: TByteArray; end; TBluetooth = class(TComponent) private { private declarations } public // Declaraciones de las funciones function BT_InitializeLibrary() : Boolean; stdcall; //1 procedure BT_UninitializeLibrary() ; cdecl; function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; //(in) function BT_IsBluetoothReady(dwSeconds: DWORD): Boolean ; stdcall; //(in) function BT_StartBluetooth() : DWord; stdcall; //5 function BT_StopBluetooth(bSwitch2HidMode: Boolean) : DWord; stdcall; //(in) function BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) function BT_SetLocalDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) function BT_GetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall;//(in, (in,out)) //10 // (in, [in o out) function BT_SetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // En c++ esta como BYTE* lpPinCode [corregir eso] function BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: Byte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in) // En c++ esta como BYTE* lpBdAddr [corregir eso] function BT_UnpairDevice( lpBdAddr: Byte) : DWORD; stdcall; // (in) //[corregir eso] // En c++ esta como BYTE* lpParam y además DWORD* lpConnectionHandle // (in, in, (in, out), out) function BT_ConnectService(pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_GENERAL_SERVICE_INFO; lpParam: BYTE; lpConnectionHandle : DWORD) : DWORD; stdcall; // (in) function BT_DisconnectService (dwConnectionHandle: DWORD): DWORD ; stdcall; // Func nº 15 [corregir eso] DWORD* lpDevsListLength, // ( in, in, (in, out), out) function BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: DWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall; function BT_CancelInquiry () :DWORD; stdcall; end; implementation //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_InitializeLibrary() : Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; //1 procedure TBluetooth.BT_UninitializeLibrary(); cdecl; external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TBluetooth.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_IsBluetoothReady(dwSeconds: DWORD) : Boolean; stdcall; external 'btfunc.dll' name 'BT_IsBluetoothReady'; function TBluetooth.BT_StartBluetooth() : DWord; stdcall; external 'btfunc.dll' name 'BT_StartBluetooth'; //5 function TBluetooth.BT_StopBluetooth(bSwitch2HidMode: Boolean) : DWord; stdcall; external 'btfunc.dll' name 'BT_StopBluetooth'; function TBluetooth.BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetLocalDeviceInfo'; function TBluetooth.BT_SetLocalDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_SetLocalDeviceInfo'; function TBluetooth.BT_GetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetRemoteDeviceInfo'; function TBluetooth.BT_SetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetRemoteDeviceInfo'; //10 function TBluetooth.BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: Byte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in) external 'btfunc.dll' name 'BT_PairDevice'; function TBluetooth.BT_UnpairDevice( lpBdAddr: Byte) : DWORD; stdcall; external 'btfunc.dll' name 'BT_PairDevice'; function TBluetooth.BT_ConnectService(pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_GENERAL_SERVICE_INFO; lpParam: BYTE; lpConnectionHandle : DWORD) : DWORD; stdcall; external 'btfunc.dll' name 'BT_ConnectService'; function TBluetooth.BT_DisconnectService (dwConnectionHandle: DWORD): DWORD; stdcall; external 'btfunc.dll' name 'BT_DisconnectService'; function TBluetooth.BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: DWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall; external 'btfunc.dll' name 'BT_InquireDevices'; //15 function TBluetooth.BT_CancelInquiry () :DWORD; stdcall; stdcall; external 'btfunc.dll' name 'BT_CancelInquiry'; end.
Escrito 20 junio 2011 - 02:58
delphi
// En c++ esta como BYTE* lpPinCode [corregir eso] function BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: Byte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in) // En c++ esta como BYTE* lpBdAddr [corregir eso] function BT_UnpairDevice( lpBdAddr: Byte) : DWORD; stdcall; // (in) //[corregir eso] // En c++ esta como BYTE* lpParam y además DWORD* lpConnectionHandle // (in, in, (in, out), out) function BT_ConnectService(pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_GENERAL_SERVICE_INFO; lpParam: BYTE; lpConnectionHandle : DWORD) : DWORD; stdcall;
function BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: PByte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in)
delphi
// Func nº 15 [corregir eso] DWORD* lpDevsListLength, // ( in, in, (in, out), out) function BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: DWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall;
function BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: PDWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall;
Escrito 20 junio 2011 - 07:22
Escrito 20 junio 2011 - 07:35
En realidad no estás traduciendo la dll sino mas bien estás realizando una interfaz de uso, o traduciendo el archivo de definiciones (.h) del C al delphi.Voy tratar de hoy o mañana terminar de traducir la dll, me quedan 14 funciones y después debo ver como realizar un ejemplo con cada una de las funciones.
Escrito 20 junio 2011 - 03:43
unit UBluetooth; {$mode objfpc}{$H+} interface uses Classes, SysUtils; type //Recor 1 T_BLUETOOTH_DEVICE_INFO = Record dwSize :DWORD ; address : TByteArray; classOfDevice : TByteArray; szName : Array[0..100] of char; bPaired: boolean; end; //Recor 2 T_BLUETOOTH_DEVICE_INFO_EX = Record dwSize : DWORD; address: TByteArray ; classOfDevice : TByteArray ; szName : Array[0..100] of char; bPaired: Boolean; ucLmpVersion: Byte; //UCHAR ; wManuName: WORD ; wLmpSubversion: WORD ; reserved : Array[0..15] of BYTE ; wClockOffset: WORD ; bConnected :Boolean ; dwDataRecvBytes: DWORD ; dwDataSentBytes: DWORD ; cSignalStrength : CHAR ; end; //Recor 3 T_SPP_CLIENT_PARAM = Record dwSize: DWORD ; ucComIndex: Byte; //UCHAR ; end; //Recor 4 T_DUN_CLIENT_PARAM = Record dwSize: DWORD; wShortcutFlags: Boolean; bAutoDial: Boolean ; szUserName: Array[0..100] of Char; password: Array[0..100] of Char; dialNumber: Array[0..100] of Char; end; //Recor 5 T_OPP_CLIENT_PARAM =Record dwSize: DWORD ; wCmdFlags: WORD ; szObjectPath: Array[0..100] of Char; end; //Recor 6 T_SYNC_CLIENT_PARAM = Record dwSize: DWORD ; bShowSyncDlg: Boolean ; ucSyncType: Byte; //UCHAR ; end; //Recor 7 T_GENERAL_SERVICE_INFO = Record dwSize: DWORD ; dwServiceHandle: DWORD ; wServiceClassUuid16: WORD ; szServiceName: Array[0..100] of Char; end; //Recor 8 T_SPPEX_SERVICE_INFO = Record dwSize: DWORD ; dwSDAPRecordHanlde: DWORD ; serviceClassUuid128: TGuid; //UUID ; szServiceName: Array[0..100] of Char; ucServiceChannel: Byte ; //uchar ucComIndex: Byte ; //uchar end; //Recor 9 T_GENERAL_CONNECT_INFO = Record dwHandle: DWORD ; bIsOutgoing: Boolean ; wServiceClasss: WORD ; remoteBdAddr: TByteArray; end; //// Estructuras de la funcion numero 24 TBluetooth = class(TComponent) private { private declarations } public // Declaraciones de las funciones function BT_InitializeLibrary() : Boolean; stdcall; //1 procedure BT_UninitializeLibrary() ; cdecl; function BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; //(in) function BT_IsBluetoothReady(dwSeconds: DWORD): Boolean ; stdcall; //(in) function BT_StartBluetooth() : DWord; stdcall; //5 function BT_StopBluetooth(bSwitch2HidMode: Boolean) : DWord; stdcall; //(in) function BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) function BT_SetLocalDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) function BT_GetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall;//(in, (in,out)) //10 // (in, [in o out) function BT_SetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // En c++ esta como BYTE* lpPinCode [corregir eso] function BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: Byte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in) // En c++ esta como BYTE* lpBdAddr [corregir eso] function BT_UnpairDevice( lpBdAddr: Byte) : DWORD; stdcall; // (in) //[corregir eso] // En c++ esta como BYTE* lpParam y además DWORD* lpConnectionHandle // (in, in, (in, out), out) function BT_ConnectService(pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_GENERAL_SERVICE_INFO; lpParam: BYTE; lpConnectionHandle : DWORD) : DWORD; stdcall; // (in) function BT_DisconnectService (dwConnectionHandle: DWORD): DWORD ; stdcall; // Func nº 15 [corregir eso] DWORD* lpDevsListLength, // ( in, in, (in, out), out) function BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: DWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall; function BT_CancelInquiry () :DWORD; stdcall; // ( in, in, (in, out), (in, out)) function BT_BrowseServices(pDevInfo: T_BLUETOOTH_DEVICE_INFO; bBrowseAllServices: Boolean; lpServiceClassListLength :DWORD; pSeriveClassList : T_GENERAL_SERVICE_INFO) :DWORD; stdcall; // en la documentacion que poseo no aclara de que tipo son // lpConnInfoLen; lpConnInfo (in, out, out, out, (in, out), out) function BT_GetConnectInfo(dwHandle : Dword; lpIsOutgoing: Boolean; lpServiceClasss: Word; lpRemoteBdAddr: BYTE; lpConnInfoLen: integer; lpConnInfo: Byte):DWORD; stdcall; function BT_StartSPPExService (pServiceInfo: T_SPPEX_SERVICE_INFO; lpServerHandle : DWORD):DWORD; stdcall; // ((in, out), out) function BT_StopSPPExService(dwServerHandle: DWORD):DWORD; stdcall;//(in) 20 // (in, (in,out), (in, out)) function BT_SearchSPPExServices (pDevInfo: T_BLUETOOTH_DEVICE_INFO; lpServiceClassListLength : DWORD; pSeriveClassList: T_SPPEX_SERVICE_INFO) :DWORD; stdcall; // (in, (in, out), out) function BT_ConnectSPPExService (pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_SPPEX_SERVICE_INFO; lpConnectionHandle: DWORD) :DWORD; stdcall; function BT_DisconnectSPPExService(dwConnectionHandle: DWord): DWORD; stdcall; // (in) { function BT_RegisterCallback(ucEvent : Byte; pfnCbkFun /* [in] */ UCHAR ucEvent, /* [in] */ LPVOID pfnCbkFun ): DWORD ; stdcall; // (in) } function BT_UnregisterCallback (ucEvent: Byte):DWORD; stdcall; // (in) 25 function BT_GetVersion():DWORD; stdcall; function BT_GetBtSpecVersion (lpBtSpecVersion: DWORD):DWORD; stdcall;//(in) function BT_EnumConnection(lpBufferLen: DWord; lpBuffer: T_GENERAL_CONNECT_INFO):DWORD; stdcall;//((in, out), out) end; implementation //external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_InitializeLibrary() : Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; //1 procedure TBluetooth.BT_UninitializeLibrary(); cdecl; external 'btfunc.dll' name 'BT_UninitializeLibrary'; function TBluetooth.BT_IsBlueSoleilStarted (dwSeconds :DWord) :Boolean; stdcall; external 'btfunc.dll' name 'BT_InitializeLibrary'; function TBluetooth.BT_IsBluetoothReady(dwSeconds: DWORD) : Boolean; stdcall; external 'btfunc.dll' name 'BT_IsBluetoothReady'; function TBluetooth.BT_StartBluetooth() : DWord; stdcall; external 'btfunc.dll' name 'BT_StartBluetooth'; //5 function TBluetooth.BT_StopBluetooth(bSwitch2HidMode: Boolean) : DWord; stdcall; external 'btfunc.dll' name 'BT_StopBluetooth'; function TBluetooth.BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetLocalDeviceInfo'; function TBluetooth.BT_SetLocalDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_SetLocalDeviceInfo'; function TBluetooth.BT_GetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetRemoteDeviceInfo'; function TBluetooth.BT_SetRemoteDeviceInfo(dwMask: DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetRemoteDeviceInfo'; //10 function TBluetooth.BT_PairDevice(pDevInfo: T_BLUETOOTH_DEVICE_INFO; wPinCodeLen: WORD; lpPinCode: Byte; bKeepOldkeyOnFail:Boolean; bShowPincode: Boolean) : DWORD; stdcall; // (in, in, in, in, in) external 'btfunc.dll' name 'BT_PairDevice'; function TBluetooth.BT_UnpairDevice( lpBdAddr: Byte) : DWORD; stdcall; external 'btfunc.dll' name 'BT_PairDevice'; function TBluetooth.BT_ConnectService(pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_GENERAL_SERVICE_INFO; lpParam: BYTE; lpConnectionHandle : DWORD) : DWORD; stdcall; external 'btfunc.dll' name 'BT_ConnectService'; function TBluetooth.BT_DisconnectService (dwConnectionHandle: DWORD): DWORD; stdcall; external 'btfunc.dll' name 'BT_DisconnectService'; function TBluetooth.BT_InquireDevices(ucInqMode : Byte; ucInqTimeLen: Byte; lpDevsListLength: DWORD; pDevsList: T_BLUETOOTH_DEVICE_INFO) :DWORD; stdcall; external 'btfunc.dll' name 'BT_InquireDevices'; //15 function TBluetooth.BT_CancelInquiry () :DWORD; stdcall; external 'btfunc.dll' name 'BT_CancelInquiry'; function TBluetooth.BT_BrowseServices(pDevInfo: T_BLUETOOTH_DEVICE_INFO; bBrowseAllServices: Boolean; lpServiceClassListLength :DWORD; pSeriveClassList : T_GENERAL_SERVICE_INFO) :DWORD; stdcall; external 'btfunc.dll' name 'BT_BrowseServices'; function TBluetooth.BT_GetConnectInfo(dwHandle : Dword; lpIsOutgoing: Boolean; lpServiceClasss: Word; lpRemoteBdAddr: BYTE; lpConnInfoLen: integer; lpConnInfo: Byte):DWORD; stdcall; external 'btfunc.dll' name 'BT_GetConnectInfo'; function TBluetooth.BT_StartSPPExService (pServiceInfo: T_SPPEX_SERVICE_INFO; lpServerHandle : DWORD):DWORD; stdcall; external 'btfunc.dll' name 'BT_StartSPPExService'; function TBluetooth.BT_StopSPPExService(dwServerHandle: DWORD):DWORD; stdcall; external 'btfunc.dll' name 'BT_StopSPPExService'; //20 function TBluetooth.BT_SearchSPPExServices (pDevInfo: T_BLUETOOTH_DEVICE_INFO; lpServiceClassListLength : DWORD; pSeriveClassList: T_SPPEX_SERVICE_INFO) :DWORD; stdcall; external 'btfunc.dll' name 'BT_SearchSPPExServices'; function TBluetooth.BT_ConnectSPPExService (pDevInfo: T_BLUETOOTH_DEVICE_INFO; pServiceInfo: T_SPPEX_SERVICE_INFO; lpConnectionHandle: DWORD) :DWORD; stdcall; external 'btfunc.dll' name 'BT_ConnectSPPExService'; function TBluetooth.BT_DisconnectSPPExService(dwConnectionHandle: DWord): DWORD; stdcall; external 'btfunc.dll' name 'BT_DisconnectSPPExService'; // falta 24 function TBluetooth.BT_UnregisterCallback (ucEvent: Byte):DWORD; stdcall; external 'btfunc.dll' name 'BT_UnregisterCallback'; function TBluetooth.BT_GetVersion():DWORD; stdcall; external 'btfunc.dll' name 'BT_GetVersion'; function TBluetooth.BT_GetBtSpecVersion (lpBtSpecVersion: DWORD):DWORD; stdcall; external 'btfunc.dll' name 'BT_GetBtSpecVersion'; function TBluetooth.BT_EnumConnection(lpBufferLen: DWord; lpBuffer: T_GENERAL_CONNECT_INFO):DWORD; stdcall;//((in, out), out) external 'btfunc.dll' name 'BT_EnumConnection'; end.
5.24 BT_RegisterCallback
This function registers an application-defined callback function for a Bluetooth event.
DWORD BT_RegisterCallback(
/* [in] */ UCHAR ucEvent,
/* [in] */ LPVOID pfnCbkFun
);
Parameters
ucEvent
[in] Specifies which event applications want to be notified. ucEvent can be one of the following value.
Value Meaning
EVENT_CONNECTION_STATUS General connection status is changed.
EVENT_DUN_RAS_CALLBACK RAS connection error occurs.
EVENT_ERROR An error occurs.
EVENT_INQUIRY_DEVICE_REPORT A remote Bluetooth device is found during Bluetooth inquiry.
EVENT_SPPEX_CONNECTION_STATUS Specific SPP connection status is changed.
EVENT_BLUETOOTH_STATUS Bluetooth is started or stopped
pfnCbkFun
[in] Pointer to the callback function that will be called when the event occurs. Prototypes of the callback functions are:
EVENT_CONNECTION_STATUS:
typedef void (*PCALLBACK_CONNECTION_STATE_CHANGED)
(WORD wServiceClass, BYTE* lpBdAddr, UCHAR ucStatus, DWROD dwConnetionHandle);
Parameters:
wServiceClass
[in] Specifies the class of the service associated with the connection.
lpBdAddr
[in] Pointer to a 6-bytes buffer containing the address of the remote device associated with the connection.
ucStatus
[in] Indicates the current connection status:
Value Meaning
STATUS_INCOMING_CONNECT An incoming connection is established.
STATUS_INCOMING_DISCONNECT An incoming connection is released.
STATUS_OUTCOMING_CONNECT An outgoing connection is established.
STATUS_OUTCOMING_DISCONNECT An outgoing connection is released.
dwConnetionHandle
[in] Handle to the connection.
EVENT_DUN_RAS_CALLBACK:
typedef void (*PCALLBACK_RAS_CONNECTION_STATE)
(UCHAR ucStrLen, CHAR* szErrorString, DWORD dwError);
EVENT_ERROR
typedef void (*PCALLBACK_ERROR) (DWORD dwErrorCode);
Parameters:
dwErrorCode:
[in] Error code. Values 0x01-0xff have the same meaning corresponding to HCI error values defined in Bluetooth Specification.
EVENT_INQUIRY_DEVICE_REPORT:
typedef void (*PCALLBACK_INQUIRY_DEVICE) (PBLUETOOTH_DEVICE_INFO pDevInfo);
Parameters:
pDevInfo
[in] Pointer to a structure of type BLUETOOTH_DEVICE_INFO containing the record of the device. Content of member szName is from BlueSoleil’s history database. If member address and classOfDevice contain all zeros, it indicates that the inquiry completes, though BlueSoleil may continue to query device names.
Remarks
A device with the same device address may be reported more than one 1 time, client applications are expected to filter duplicated devices.
EVENT_SPPEX_CONNECTION_STATUS:
typedef void (*PCALLBACK_SPPEX_CONNECTION_STATUS) (DWORD dwServerHandle, BYTE* lpBdAddr, UCHAR ucStatus, DWORD dwConnetionHandle);
Parameters:
dwServerHandle
[in] The handle to the specific SPP service. By comparing to the handle returned by BT_StartSPPExService, dwServerHandle can be used to retrieve related service information, e.g. COM port associated to the service.
lpBdAddr
[in] Pointer to a 6-bytes buffer containing the address of the remote device associated with the connection. The address is invalid if ucStatus is STATUS_INCOMING_DISCONNECT.
ucStatus
[in] Connection status:
Value Meaning
STATUS_INCOMING_CONNECT An incoming connection is established.
STATUS_INCOMING_DISCONNECT An incoming connection is released.
dwConnetionHandle
[in] Reserved.
EVENT_BLUETOOTH_STATUS:
typedef void (*PCALLBACK_BLUETOOTH_STATUS) (UCHAR ucStatus);
Parameters:
ucStatus
[in] Indicates the current status of Bluetooth, this parameter is one of the following value:
Value Meaning
STATUS_BLUETOOTH_STARTED Bluetooth is started.
STATUS_BLUETOOTH_STOPED Bluetooth is stoped.
Return Values
BTSTATUS_SUCCESS if the function succeeds.
BTSTATUS_PARAMETER_ERROR if parameter(s) is (/are) not correct
BTSTATUS_BT_NOT_READY if Bluetooth is not started.
BTSTATUS_SYSTEM_ERROR if system error(s) occurs.
BTSTATUS_FAIL if the function fails for other reasons.
Remarks
If BlueSoleil exits, all registered events will be discarded, the associated callbacks will not work after BlueSoleil is restarted. To keep callbacks working, an application must call BT_UninitializeLibrary when it detects BlueSoleil exits, and call BT_InitializeLibrary and BT_RegisterCallback again after BlueSoleil is restarted.
It is recommended that, the Bluetooth APIs defined in this document should not be called in the users’ callback functions registered by BT_RegisterCallback to prevent any potential deadlock in codes.
Escrito 20 junio 2011 - 04:36
var s: String; u: PBYTE; begin s := 'hola'; u := PBYTE(@s[1]); u := PBYTE(PCHAR(s)); end;
uses Math; var dw: DWORD; begin dw:= Floor(1.2); // dw = 1 end;
Escrito 22 junio 2011 - 01:07
Escrito 26 junio 2011 - 12:54
function BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out)
procedure TForm1.BTN_BT_GetLocalDeviceInfoClick(Sender: TObject); var secons: DWord; BdI: T_BLUETOOTH_DEVICE_INFO_EX; begin secons:= StrToDword(e_BT_GetLocalDeviceInfo.text); // bl.BT_GetLocalDeviceInfo(secons, BDI); //no anda // DBI:= bl.BT_GetLocalDeviceInfo(secons, BDI); //no anda // DBI:= bl.BT_GetLocalDeviceInfo(secons, ^BDI); //no anda // DBI:= bl.BT_GetLocalDeviceInfo(secons, &BDI); //no anda // DBI:= bl.BT_GetLocalDeviceInfo(secons, *BDI); //no anda cargar_Bluetooth_Device_info_ex(secons, BdI); end; La funciones cargar_bluetooth_device_info_ex sirve para pasar los datos del registro del tipo T_Bluetooth_device_info_ex a distintas cajas de texto para poder ver lo que devuelve [code=delphi:0] procedure TForm1.cargar_Bluetooth_Device_info_ex(BdeviceInfo: T_BLUETOOTH_DEVICE_INFO_EX); begin e_DI_dwsize.Text:= IntToStr(BdeviceInfo.dwSize); // e_DI_address.Text:= BdeviceInfo.address; //no se como addres es un TByteArray // e_DI_classofdevice.Text:= BdeviceInfo.classOfDevice; // no se como cllasofdevie es un TByteArray e_DI_szname.Text:= BdeviceInfo.szName; e_DI_bparied.Text:= BoolToStr(BdeviceInfo.bPaired); e_DI_uclmpversion.Text:= inttostr(BdeviceInfo.ucLmpVersion); e_DI_wmanuname.Text:= inttostr(BdeviceInfo.wManuName); e_DI_wlmpsubversion.Text:= inttostr(BdeviceInfo.wLmpSubversion); // e_DI_reserved.Text:= BdeviceInfo.reserved; // no se como reserved es un array of byte[0..15] e_DI_wclockoffset.Text:= inttostr(BdeviceInfo.wClockOffset); e_DI_bconnected.Text:= BoolToStr(BdeviceInfo.bConnected); e_DI_dwdatarecbbytes.Text:= inttostr(BdeviceInfo.dwDataRecvBytes); e_DI_dwdatasentbytes.Text:= inttostr(BdeviceInfo.dwDataSentBytes); // e_DI_csignalstrength.Text:= inttostr(BdeviceInfo.cSignalStrength); // no se como, es un char end;
Escrito 26 junio 2011 - 07:39
function BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) procedure BT_GetLocalDeviceInfo2(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO); cdecl;// (in, out)
function TBluetooth.BT_GetLocalDeviceInfo(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO): DWORD; stdcall; // (in, out) external 'btfunc.dll' name 'BT_GetLocalDeviceInfo'; procedure TBluetooth.BT_GetLocalDeviceInfo2(dsMask : DWORD; pDevInfo: T_BLUETOOTH_DEVICE_INFO); cdecl; external 'btfunc.dll' name 'BT_GetLocalDeviceInfo';
procedure TForm1.BTN_BT_GetLocalDeviceInfoClick(Sender: TObject); var secons: DWord; result: DWord; BdI: T_BLUETOOTH_DEVICE_INFO; begin secons:= StrToDword(e_BT_GetLocalDeviceInfo.text); result := bl.BT_GetLocalDeviceInfo(secons, BDI); bl.BT_GetLocalDeviceInfo2(secons, BdI); e_BT_GetLocalDeviceInfoOut.Text:= IntToStr(result); cargar_Bluetooth_Device_info(BdI); end;