c# - Java DLL Function: Connecting to MicroFocus Rumba ehlapi32 -


i have issue i've been trying solve months now. trying connect microfocus rumba using ehlapi32.dll library in java. there not many references online java. have tried loading them using jna, continue receiving '1' status means process given incorrect. not sure if issue of declaring function correctly or possibly process. have manually provided processid using windows cmd 'tasklist' , finding wddsppag.bin pid.

i have written many vb programs , connect fine following:

declare function wd_connectps lib "ehlapi32.dll" (byval hinstance long, byval shortname string) integer declare function wd_copypstostring lib "ehlapi32.dll" (byval hinstance long, byval position integer, byval buffer string, byval length integer) integer declare function wd_copystringtops lib "ehlapi32.dll" (byval hinstance long, byval position integer, byval buffer string, byval length integer) integer declare function wd_sendkey lib "ehlapi32.dll" (byval hinstance long, byval keydata string) integer declare function wd_disconnectps lib "ehlapi32.dll" (byval hinstance long) integer 

my issue process, in vb declare this:

declare function getcurrentprocessid lib "kernel32" () long 

so know if process being declared correctly? if can manually enter process testing purposes? suppose need "find" rumba process, below code seems give me process jvm using?

    import com.sun.jna.library;     import com.sun.jna.native;     import com.sun.jna.platform;     import com.sun.jna.platform.win32.kernel32;       public class rumbaconnect {            public interface ehlapi32 extends library {              ehlapi32 ehlapi32 = (ehlapi32) native.loadlibrary(                     (platform.iswindows() ? "ehlapi32" : "ehlapi32"), ehlapi32.class);                 public int wd_connectps(long hinstance , string shortname);                 public int wd_disconnectps(long hinstance);             }         public static final ehlapi32 ehlapi32 = (ehlapi32) native.loadlibrary("ehlapi32", ehlapi32.class);            public static final kernel32 kernel32 = (kernel32) native.loadlibrary("kernel32", kernel32.class);             public static void main(string[] args) {              int process = 0;               int status = 0;                process = kernel32.getcurrentprocessid();              status = ehlapi32.wd_connectps(process, "a");             // status = getprocaddress.wd_connectps(5976, "a");                 system.out.println("your rumba status: " + status);           }         /*  0  function successful               1  incorrect psid specified               8  no prior call start communication notification (80) function called psid               9  system error encountered           */     } 

finally, expected result should 'zero,' provided in java comments. in advance. libraries load fine, set path in eclipse via eclipse -> windows -> pref -> java -> installed jres -> edit default jre -> , entered "-djava.library.path=c:\windows\system32;c:\rumba\system" don't believe loading libraries issue.

edit:

additionally, vb code above used in msaccess , ms excel, there reference libraries loaded default , works declaration of function. this:

declare function wd_connectps lib "ehlapi32.dll" (byval hinstance long, byval shortname string) integer 

only instance , rumba window (in case "a") passed, returns status of either '0' means active , ready, or other code (see code comments).

i figured out problem. turns out hinstance needs declared 'int' , not 'long.' after continued playing around code able communicate java , send string. code below in case example. actual working code connects , sends string. able add of ehlapi functions ease code below:

import com.sun.jna.library; import com.sun.jna.native; import com.sun.jna.platform; import com.sun.jna.platform.win32.kernel32;   public class rumbaconnect {        public interface ehlapi32 extends library {          ehlapi32 ehlapi32 = (ehlapi32) native.loadlibrary(                 (platform.iswindows() ? "ehlapi32" : "ehlapi32"), ehlapi32.class);             public int wd_connectps(int hinstance , string shortname);             public int wd_sendkey(int hinstance, string keydata);         }     public static final ehlapi32 ehlapi32 = (ehlapi32) native.loadlibrary("ehlapi32", ehlapi32.class);        public static final kernel32 kernel32 = (kernel32) native.loadlibrary("kernel32", kernel32.class);         public static void main(string[] args) {          int process = 0;           int status = 0;           int intresult = 0;            process = kernel32.getcurrentprocessid();          status = ehlapi32.wd_connectps(process, "a");          intresult = ehlapi32.wd_sendkey(process, "myname");             system.out.println("your rumba status: " + status);       }     /*  0  function successful           1  incorrect psid specified           8  no prior call start communication notification (80) function called psid           9  system error encountered       */ } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -