Forums Register Login

Invoking methods within a DLL written in VB

+Pie Number of slices to send: Send
OK, so I've never tried to use JNI before, but I'm giving it a try. My goal here is to be able to invoke a method within a DLL that was written in VB.
I started by going through the JNI tutorial. That was great, but, from what I can tell, it is only possible to interface with a DLL written in C/C++.
I did a bit more research and it looks like it's possible to invoke a method within a VB DLL by creating a C/C++ DLL and having that DLL invoke the method I want to invoke, like this:

It isn't pretty, but it seems to be the only way to really go about this.
So, I've written the following two pieces - first, the Java code:

Next, I wrote the C to create the "wrapper" dll:

This part of it works great - if I try to run my Java application, the method within the C DLL is invoked and the application prints out "Hello world!" to the console.
Now, for the last part. How do I make the C DLL invoke a method of the VB DLL? This definitely goes outside my realm of expertise and I just don't know how to do that. Any help would be greatly appreciated.
Thanks,
Corey
+Pie Number of slices to send: Send
Well it looks to me that you know C, so why not just rewrite the vb dll in C.
Mark
+Pie Number of slices to send: Send
You can call whatever dll you want dynamically from you C++ DLL. You only have to know its name and the methodname you want to call.
Here is a code snippet that might help:

We called Turbo Pascal or Delphi DLLs with this method. So I think VB works too. You can also use this method if you use a third party DLL and you don't have the lib file to bind it statically.
Hope that helps.
+Pie Number of slices to send: Send
JINI is not a lot of fun. Nor was it ever intended for mere mortal programmers (like me) - or everyday use.
I've used the quite nice library JAWIN. I recommend you do too. It works pretty well.
See http://sourceforge.net/projects/jawinproject/
Beware the other head of science - it bites! Nibble on this message:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1390 times.
Similar Threads
JNI Program RunTime Exceptions
JNI What is it, and can I use it
JNI example gives UnsatisfiedLinkError
Returning String to Java from C via JNI
jni.h incorrect
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:23:58.