I am trying to use openVR dll from delphi. However, this dll got only limited function exported, a lot of function is stay inside interfaces.
since there are some samples for using openVR, so I take a look at c version header and a c# version header to see how they do that.
I do not get quite knowledge from the c header, while in the c# header, I notice they are using some struct(like interface in delphi) to store the function table, and have an class (like implementation class in delphi) for that struct, inside the class there is an create function witch seems like hack the pointer to all these functions.
IVRSystem FnTable;
internal CVRSystem(IntPtr pInterface)
{
FnTable = (IVRSystem)Marshal.PtrToStructure(pInterface, typeof(IVRSystem));
}
The pInterface
pointer is given at a big class which contains a set of the implementation class.
public CVRSystem VRSystem()
{
CheckClear();
if (m_pVRSystem == null)
{
var eError = EVRInitError.None;
var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix+IVRSystem_Version, ref eError);
if (pInterface != IntPtr.Zero && eError == EVRInitError.None)
m_pVRSystem = new CVRSystem(pInterface);
}
return m_pVRSystem;
}
where OpenVRInterop.GetGenericInterface
is one of the exported function by dll.
So my problem are :
(1) can delphi did something like what C# does? it seems like he call these functions just by the raw pointer (address? offset?) I searched for delphi deal with dll, only for two ways(static and dynamics) both require function names.
function someFunction(a : integer) :integer; stdcall; external ’someDll.dll’;
dllHandle := LoadLibrary(’someDll.dll’);
@someFunction := GetProcAddress(dllHandle,'someFunction');
(2) How is the c header did the library load? I did not find related code there.