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.
PJavaVM = ^JavaVM;
PJNIEnv = ^JNIEnv;
MainJVM : JavaType.PJavaVM;
// Setting the 'MainJVM' variable (from the main thread) within a procedure
env : JavaType.PJNIEnv
// Attaching MainJVM's thread to 'env' (which isn't working) within a procedure
env : JavaType.PJNIEnv;
Everything seems to be working up to the 'AttachCurrentThread' line. That line returns a 0 but the value of 'env' isn't updated.