H
Homer
Hi All,
For god sake, can anybody email me ([email protected] remove
the obvious part) or to the newsgroup small sample function how to call
a callback function from C++ and pass a Jstring to Java? I don't need
MultiThread and anything special. Just a simple call. I am not good in
C++ and this Vstudio is making me crazy. This is as far as I came:
void doCallback(){
jclass cls = (*environment)->GetObjectClass(environment, object);
jmethodID mid = *environment->GetMethodID(cls, "callback", "()V");
if (mid == 0) {
return;
}
*environment->Java_DirectoryWatcher_nativeMethod(object, mid,
myString);
}
JNIEXPORT void JNICALL
Java_DirectoryWatcher_nativeMethod(JNIEnv *env, jobject obj, jString
msg)
{
jclass cls = env->GetObjectClass(obj);
jmethodID mid = env->GetMethodID(cls, "callback", "(I)V");
if (mid == 0) {
return;
}
env->CallVoidMethod(obj, mid, depth);
}
Thanks,
Homer
For god sake, can anybody email me ([email protected] remove
the obvious part) or to the newsgroup small sample function how to call
a callback function from C++ and pass a Jstring to Java? I don't need
MultiThread and anything special. Just a simple call. I am not good in
C++ and this Vstudio is making me crazy. This is as far as I came:
void doCallback(){
jclass cls = (*environment)->GetObjectClass(environment, object);
jmethodID mid = *environment->GetMethodID(cls, "callback", "()V");
if (mid == 0) {
return;
}
*environment->Java_DirectoryWatcher_nativeMethod(object, mid,
myString);
}
JNIEXPORT void JNICALL
Java_DirectoryWatcher_nativeMethod(JNIEnv *env, jobject obj, jString
msg)
{
jclass cls = env->GetObjectClass(obj);
jmethodID mid = env->GetMethodID(cls, "callback", "(I)V");
if (mid == 0) {
return;
}
env->CallVoidMethod(obj, mid, depth);
}
Thanks,
Homer