K kohle Active Member Licensed User Longtime User May 28, 2019 #1 Hi, in an other language I use the windows api function : ShellExecuteA( hwnd, lpOperation, lpFile, lpParameters , lpDirectory, nShowCmd ) Code: Copy ulong nShowCmd = 1 // Normal open setNull(lpOperation) ShellExecuteA( hwnd, lpOperation, "c:\mydoc\test.doc", "" , "", nShowCmd ) How can I open a file in B4J with the associated program without knowing name and location of the program. Thanks
Hi, in an other language I use the windows api function : ShellExecuteA( hwnd, lpOperation, lpFile, lpParameters , lpDirectory, nShowCmd ) Code: Copy ulong nShowCmd = 1 // Normal open setNull(lpOperation) ShellExecuteA( hwnd, lpOperation, "c:\mydoc\test.doc", "" , "", nShowCmd ) How can I open a file in B4J with the associated program without knowing name and location of the program. Thanks
Philip Chatzigeorgiadis Active Member Licensed User Longtime User May 28, 2019 #2 Here is how I do it: Code: Copy dim fx as Jfx fx.showexternaldocument(File.geturi("directory","filename")) Upvote 0
Here is how I do it: Code: Copy dim fx as Jfx fx.showexternaldocument(File.geturi("directory","filename"))
K kohle Active Member Licensed User Longtime User May 28, 2019 #3 I get an error, Code: Copy Waiting for debugger to connect... Program started. file:/C:/000_test/new_Document2.docx Error occurred on line: 152 java.lang.NullPointerException at anywheresoftware.b4j.objects.JFX.ShowExternalDocument(JFX.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:656) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:232) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90) at anywheresoftware.b4a.BA.raiseEvent(BA.java:84) at b4j.example.main.main(main.java:29) Upvote 0
I get an error, Code: Copy Waiting for debugger to connect... Program started. file:/C:/000_test/new_Document2.docx Error occurred on line: 152 java.lang.NullPointerException at anywheresoftware.b4j.objects.JFX.ShowExternalDocument(JFX.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:656) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:232) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90) at anywheresoftware.b4a.BA.raiseEvent(BA.java:84) at b4j.example.main.main(main.java:29)
K kohle Active Member Licensed User Longtime User May 28, 2019 #4 see the problem, Erel : Yes. You cannot use jFX from a non-UI application. Upvote 0
K kohle Active Member Licensed User Longtime User May 28, 2019 #5 Is there a way in a non-UI-application ? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 28, 2019 #6 If you are only targeting windows then you can use jShell and run cmd /c with the program (exact parameters might be different). Upvote 0
If you are only targeting windows then you can use jShell and run cmd /c with the program (exact parameters might be different).
K kohle Active Member Licensed User Longtime User May 28, 2019 #7 I think with the cmd the path variable of windows must be set to the program. I tried it like this with the UI version : Dont load the form, start the external program and after this I close the app with the ExitApplication command. Looks for me the same like an non-ui app. Thanks to all. Upvote 0
I think with the cmd the path variable of windows must be set to the program. I tried it like this with the UI version : Dont load the form, start the external program and after this I close the app with the ExitApplication command. Looks for me the same like an non-ui app. Thanks to all.