| |

VerySource

 Forgot password?
 Register
Search
View: 20|Reply: 12

java how to call vb dll

[Copy link]

1

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: 2020-3-6 02:00:02
| Show all posts |Read mode
I want to call an encryption dll written in vb in java. I found some examples on the Internet that call dll written in vc through JNI. How do I call the vb dll?
Reply

Use magic Report

0

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-5-22 20:15:01
| Show all posts
java-jni-dll

So what you have to solve is just how to call dll (vb) in jni (dll). It is estimated that there is no problem with the dll of stdcall
Reply

Use magic Report

1

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-6-1 16:30:02
| Show all posts
I found a way through jacobdiaoy.
But there are still some questions. Where should the dll to be called be placed and then what configuration should be done?
Reply

Use magic Report

1

Threads

39

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

Post time: 2020-6-2 06:15:02
| Show all posts
class TestDLL {
        static{
                System.loadLibrary("mydll");
        }
        public native int sayHello(int i);

        public static void main(String[] args){
                System.out.print(new TestDLL().sayHello(1));
        }
}
Reply

Use magic Report

1

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-6-3 08:15:01
| Show all posts
The third floor is called by jni. The dll generated by jni seems to be more complicated. What I can make is also some dll generated by vc.
For the call of vb dll, I now call it through jacob. What path should the dll to be called be placed and what kind of configuration should be done? Does anyone know? The following is my calling program. If the comment part is not added, the compiler will pass, indicating that the jacob call is OK, but if the comment part is also included, it will report that there is no app.EncryptString method error. There is a problem with the path configuration, can anyone give some pointers?
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Variant;

public class UserKit{
public static void main(String[] args){
ActiveXComponent app = new ActiveXComponent("UserKit.clsRC4");
String str = "This is a test about jacob!";
//String enstr = app.EncryptString(str,"admin");
//System.out.println(enstr);
}
}
Reply

Use magic Report

0

Threads

4

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-6-4 15:15:01
| Show all posts
class TestDLL {
        static{
                System.loadLibrary("mydll");
        }
        public native int sayHello(int i);

        public static void main(String[] args){
                System.out.print(new TestDLL().sayHello(1));
        }
}
---------------------------------------
  "mydll" is the file name? Where should I put it?
Reply

Use magic Report

0

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-6-7 20:15:01
| Show all posts
I developed with netbean, "mydll" is the name of the dll file generated by the jni method. In the development environment, I put it in the root directory of the project, and the called dll is also placed in that directory; after the executable file is generated, the two dll and Just put that jar file in a directory
Reply

Use magic Report

1

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 Philippines

 Author| Post time: 2020-6-11 09:00:01
| Show all posts
The upstairs implementation method is still through the jni method, a method under syHello() and dll is mapped, but I do not know the process of this mapping.
I looked at Jacob's dll call, which can generate an ActiveXComponent object, for example, it can be generated by ActiveXComponent app = new ActiveXComponent("proID"); but how to call the method in dll through this app? I won't do it anymore. I add some points after the app and give out the method hints in the dll. This is different from what I thought. I won't do it here.
Please tell me a friend who knows.
Reply

Use magic Report

0

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-6-15 11:30:01
| Show all posts
jacob should not be suitable for your dll, jacob is a bridge between java and Microsoft's com component, through the use of jacob's own dll dynamic link library, the method on the sun java platform is used to call com. Don't be afraid of trouble, it is better to start with JNI.
Reply

Use magic Report

1

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-6-19 12:15:01
| Show all posts
I basically got it, although I don’t understand it, but I used the dll anyway.
UserKit is the name of the dll, clsRC4 is the module in the dll project, EncrytString and DecrytString are encryption and decryption methods, each method has two parameters: one is the original text (ciphertext), and the other is the key.
Of course, the process I did was not very understanding of Dispatch and Variant objects.
package jacob;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.*;

public class Kit {
The
public static void main(String args[]){
ActiveXComponent app = new ActiveXComponent("UserKit.clsRC4");
Dispatch mycom = (Dispatch)app.getObject();
String s[] = new String[2];
s[0] = new String("ttt");
s[1] = new String("admin");
Variant result = Dispatch.callN(mycom, "EncryptString", s);
System.out.print(result);
String es[] = new String[2];
es[0] = new String("M2t");
es[1] = new String("admin");
Variant dresult = Dispatch.callN(mycom, "DecryptString",es);
System.out.print(dresult);
The
The
}

}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list