Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Invoking methods within a DLL written in VB  RSS feed

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it looks to me that you know C, so why not just rewrite the vb dll in C.
Mark
 
Peter Storch
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Simon Pearce
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!