Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

C++ wrapper

843829Jun 16 2003 — edited Jun 28 2003
I am writing a c++ dll wrapper for a delphi dll so I can use JNI. It is all pretty messed up and I have everything working except for a few functions that take a delphi "procedure" pointer as an argument and then callback this procedure.

The Delphi documentation for the method in the dll is:


The relevant bits from my c++ header file are:

typedef int (CALLBACK* ToziMapDblClickON)(int *);
extern ToziMapDblClickON oziMapDblClickON;

The relevant bits from the cpp file are:

ToziMapDblClickON oziMapDblClickON;

void MapDblClickCallback(LPSTR oType,int x, int y, double Lat, double Lon,LPSTR UTMZone, double easting, double northing)
{
printf("Callbacktest");


}

JNIEXPORT jint JNICALL Java_oziphoto_nat_OZIJava_joziMapDblClickON
(JNIEnv * env, jclass jcla)
{
printf("start");
int i = oziMapDblClickON((int *)&MapDblClickCallback);
printf("end");
return i;
}

int LoadOziApiDll(void)
{
oziApiDll = LoadLibrary("oziapi.dll");
if (oziApiDll == NULL) {return -1;}
oziMapDblClickON = (ToziMapDblClickON)GetProcAddress(oziApiDll,"oziMapDblClickON");
if (!oziMapDblClickON) { FreeLibrary(oziApiDll);return -2;}
return 0;
}

When I call my function from Java my console prints "startCallbacktestend". Essentially the MapDblClickCallback function is being called as it is being passed to the oziMapDblClickON function in the delphi dll. When I double click in the program I am interfacing with I would expect the callback to be executed. It is not. I know that the program I am interfacing with has recieved the oziMapDblClickCallback request as it no longer processed the events in the normal way.

I think that there may be something wrong with the way I am passing the function pointer (if that is what it is) to the oziMapDblClickON function. Any ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2003
Added on Jun 16 2003
6 comments
151 views