Call .dll functions using Java

NicuVlad

I need to write an application for a client that calls a method from a ".dll" file. The ".dll" file was previously executed manually from an ".exe" GUI but now they want to automate the process.

I never worked with .dll files so everything that I found until now is the result of a complete day of research, I also received a small documentation with this tool:

The interface is an ActiveX DLL which provides two functions (GetUnitInfo and SaveResult).

In the moment I just want to run the "GetUnitInfo" method from the Winwdows command line using RUNDLL32.exe.

This is the documentation for the "GetUnitInfo" method: The interface for GetUnitInfo is as follows:

Public Function GetUnitInfo( _
ByVal strRequest As String, _
ByRef strUnitInfo As String,
Optional ByVal strStationName As String = "") As Long

Sample calling code can be:

Dim lRet As Long
    Dim strXML as String
    lRet = GetUnitInfo( _“<?xml version=""1.0"" ?><GetUnitInfo 
    xmlns=""urn:GetUnitInfo-schema"" SerialNumber=""BD3ZZTC8MA"" />",  strXML)

So I tried to run this method with some dummy parameters because the method returns an error if the parameters are not OK. The command:

RUNDLL32.EXE FFTester.dll, GetUnitInfo test1, test2

But I receive this error:

enter image description here

I used "Dependency Walker" to list the functions from the dll file: enter image description here

But this are all the functions, normally I would expected that also "GetUnitInfo" is listed.

Can somebody help? It is not mandatory to use RUNDLL32.

Later edit: I want to call this DLL from a tool that is written in JAVA, I tried to use JNA but I failed so I was thinking to call the dll functions from the command line because if this works I can use a process builder to execute the command.

NicuVlad

I fixed my problem and I will provide a solution, maybe it will help someone else.

I used com4j library to generate the interfaces for my dll. After this you need to register your DLL otherwise most problely your code will throw an "ComException", you can read more in my second question. To register a DLL:

C:\Windows\SysWOW64>regsvr32.exe "path to your DLL" for 32 bit DLL

Or

C:\Windows\System32>regsvr32.exe "path to your DLL" for 64 bit DLL

Also depending on your DLL type, 32 or 64 bit, you need to use proper Eclipse/JDK.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to call dll files in java

From Java

Using exec() functions to Call Linux Command in C

From Java

Microsoft Visual Foxpro DLL call in Node or Java

From Java

Call C# dll from a Java Application

From

Golang: call Windows DLL functions

From Dev

LInk to ntdll.lib and call functions inside ntdll.dll

From Dev

GHC: how to build a 32-bit DLL using 64-bit GHC? (To call functions from c++)

From Dev

Arrow functions using call, apply, bind - not working?

From Java

Why I am able to call a non-void functions without using the returned values in java?

From Dev

Using functions as arguments - how to call?

From Dev

Call fortran dll from java using JNI

From Dev

Wrapping DLL functions using ctypes

From Dev

How to call functions using Python Arrow Syntax

From Dev

Using Ctypes to Configure DLL functions

From Dev

How to call bound functions / actions inside Java client using SAP Cloud SDK?

From Dev

Calling jQuery functions using call or apply

From Dev

Using _stdcall will change name of exported functions in dll

From Dev

Using jQuery to call functions

From Dev

Attempted to read or write protected memory when using reflection to call dll functions

From Dev

How to call DLL function using "&" parameter?

From Dev

Call a function of VB DLL file from java using JNA

From Dev

How to call csImageFile.dll (com) functions in c#

From Dev

using variables to call jquery functions

From Dev

Call functions dynamics of DLL's inside a Web Service C#

From Dev

adding a dll to c# project and using the dll functions

From Dev

How to call the separate functions file using php?

From Dev

How to call a php functions using ajax and case

From Dev

Call DLL written in Delphi from Java

From Dev

Call functions using dictionaries in python

Related Related

  1. 1

    How to call dll files in java

  2. 2

    Using exec() functions to Call Linux Command in C

  3. 3

    Microsoft Visual Foxpro DLL call in Node or Java

  4. 4

    Call C# dll from a Java Application

  5. 5

    Golang: call Windows DLL functions

  6. 6

    LInk to ntdll.lib and call functions inside ntdll.dll

  7. 7

    GHC: how to build a 32-bit DLL using 64-bit GHC? (To call functions from c++)

  8. 8

    Arrow functions using call, apply, bind - not working?

  9. 9

    Why I am able to call a non-void functions without using the returned values in java?

  10. 10

    Using functions as arguments - how to call?

  11. 11

    Call fortran dll from java using JNI

  12. 12

    Wrapping DLL functions using ctypes

  13. 13

    How to call functions using Python Arrow Syntax

  14. 14

    Using Ctypes to Configure DLL functions

  15. 15

    How to call bound functions / actions inside Java client using SAP Cloud SDK?

  16. 16

    Calling jQuery functions using call or apply

  17. 17

    Using _stdcall will change name of exported functions in dll

  18. 18

    Using jQuery to call functions

  19. 19

    Attempted to read or write protected memory when using reflection to call dll functions

  20. 20

    How to call DLL function using "&" parameter?

  21. 21

    Call a function of VB DLL file from java using JNA

  22. 22

    How to call csImageFile.dll (com) functions in c#

  23. 23

    using variables to call jquery functions

  24. 24

    Call functions dynamics of DLL's inside a Web Service C#

  25. 25

    adding a dll to c# project and using the dll functions

  26. 26

    How to call the separate functions file using php?

  27. 27

    How to call a php functions using ajax and case

  28. 28

    Call DLL written in Delphi from Java

  29. 29

    Call functions using dictionaries in python

HotTag

Archive