Using .dll files in Readyapi
Hi,
In our c# development environment we use some .dll files (bought from external company) to convert files in different formats to .pdf.
Is there a way to use these .dll files in some way also via Readyapi?
I.e. I would like to point out a, let say, .jpeg file and then call the method found in the .dll files to convert it to .pdf?
Is this possible at all?
Hello amirse
Here is a sample groovy script that I hacked up from original source found from the link in the code. Put it in a Groovy Test Step to try it out. It just goes against the Microsoft Windows supplied kernel32.dll that is on Windows computers. It looks like the important part of the code is to get the interface method calls correct. Finding the interface definition for your .DLL will probably be the tricky part. This sample does not rely on any special tool pre-process or anything other than the imported libraries that are supplied with ReadyAPI (JNA). Good Luck.
Regards,
Todd
import com.sun.jna.Library; import com.sun.jna.Native; // source: // https://www.codeproject.com/Questions/625580/calling-dll-function-java //** Simple example of Windows native library declaration and usage. */ //public class BeepExampl{ // public interface Kernel32 extends Library { // // FREQUENCY is expressed in hertz and ranges from 37 to 32767 // // DURATION is expressed in milliseconds // public boolean Beep(int FREQUENCY, int DURATION); // public void Sleep(int DURATION); // } // public static void main(String[] args) { // Kernel32 lib = (Kernel32) Native.loadLibrary("kernel32", // Kernel32.class); // lib.Beep(698, 500); // lib.Sleep(500); // lib.Beep(698, 500); // } //} // log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" start...'; log.info ""; interface Kernel32 extends Library { boolean Beep(int FREQUENCY, int DURATION); void Sleep(int DURATION); }; Kernel32 lib = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class); lib.Beep(698, 500); lib.Sleep(1000); lib.Beep(698, 1000); log.info ""; log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" done...';