Here are a bunch of snippets of my code (written in Pascal). I tried to grab all of the important parts - let me know if I missed anything.
//type declarations
PJavaVM = ^JavaVM;
PJNIEnv = ^JNIEnv;
...
//global variable
var
MainJVM : JavaType.PJavaVM;
...
// Setting the 'MainJVM' variable (from the main thread) within a procedure
var
env : JavaType.PJNIEnv
...
env^^.GetJavaVM(env,MainJVM);
...
// Attaching MainJVM's thread to 'env' (which isn't working) within a procedure
var
env : JavaType.PJNIEnv;
...
MainJVM^^.AttachCurrentThread(MainJVM,@env,nil)
Everything seems to be working up to the 'AttachCurrentThread' line. That line returns a 0 but the value of 'env' isn't updated.
Thanks!