Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Invoking methods within a DLL written in VB

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic