I'm with a little trouble when pointing to a subclass of an API.
Here is the original pascal code of what am I trying to do:
Adapter:=TJBluetoothAdapter.JavaClass.getDefaultAdapter;
remoteDevice:=Adapter.getRemoteDevice(stringtojstring(targetMACAddress));
sock:=remoteDevice.createRfcommSocketToServiceRecord(UID);
Reduced version of it:
sock:=TJBluetoothAdapter.JavaClass.getDefaultAdapter.getRemoteDevice(stringtojstring(targetMACAddress)).createRfcommSocketToServiceRecord(UID);
Here I have what I've already tried to do:
_di_JBluetoothSocket* sock = new _di_JBluetoothSocket;
sock = &TJBluetoothAdapter::JavaClass->getDefaultAdapter()->getRemoteDevice(StringToJString(targetMACAddress))->createRfcommSocketToServiceRecord(uid);
and:
TJBluetoothAdapter::JavaClass->getDefaultAdapter()->getRemoteDevice(StringToJString(targetMACAddress))->createRfcommSocketToServiceRecord(uid)* sock;
and:
TJBluetoothAdapter* sock;
sock = TJBluetoothAdapter::JavaClass->getDefaultAdapter()->getRemoteDevice(StringToJString(targetMACAddress))->createRfcommSocketToServiceRecord(uid);
However I always get error when compilling, what should I do? Since now, thanks for your advice.
You are declaring your
sock
variable incorrectly. Do not declare a pointer to a_di_...
class type. It is already a pointer (more specifically, it is a typedef for theSystem::DelphiInterface
class, which is a C++ smart pointer wrapper around a Delphi interface pointer).Which is roughly equivalent to this: