This awesome (when you think what is going on here) demonstration program shows a B4J application running VBScript code on a Windows ActiveX object, the MS Script Control, hosted by a .NET managed library written in C#.
The more technically competent amongst you can now access Windows resources from your B4J application following the template given here by writing a couple of libraries that talk to each other across a native code interface. The Java native code interface is provided by the Java JNA library and the .NET code native interface is provided by a Visual Studio NuGGet, UnmanagedExports, that post processes the managed library to expose managed method calls as native ones.
The archive contains a document, UnmanagedExports.rtf, that reveals the gory details in all (well most) of their splendour. Familiarity with a Java IDE or at least Java code and the Simple Library Compiler will be needed to create your own B4J library. Familiarity with Visual Studio and a .NET language will be needed to generate your .NET library that exposes whatever Windows functionality you require, be it via COM Interop or P/Invoke. Source code for both libraries used in this demo is included in the library archive.
I overlooked an early problem I had, see post #3. You need to open jna-4.0.0.jar with 7-Zip, double click on META-INF, select and right-click on MANIFEST.MF and select Edit. It will open in Notepad. Find the line "Implementation-version: 4.0.0 (b2)" and either delete the entire line or edit it to read "Implementation-version: 4.0.0". Save and exit Notepad and 7-Zip should ask if you want to update the archive - which you do.
The more technically competent amongst you can now access Windows resources from your B4J application following the template given here by writing a couple of libraries that talk to each other across a native code interface. The Java native code interface is provided by the Java JNA library and the .NET code native interface is provided by a Visual Studio NuGGet, UnmanagedExports, that post processes the managed library to expose managed method calls as native ones.
The archive contains a document, UnmanagedExports.rtf, that reveals the gory details in all (well most) of their splendour. Familiarity with a Java IDE or at least Java code and the Simple Library Compiler will be needed to create your own B4J library. Familiarity with Visual Studio and a .NET language will be needed to generate your .NET library that exposes whatever Windows functionality you require, be it via COM Interop or P/Invoke. Source code for both libraries used in this demo is included in the library archive.
I overlooked an early problem I had, see post #3. You need to open jna-4.0.0.jar with 7-Zip, double click on META-INF, select and right-click on MANIFEST.MF and select Edit. It will open in Notepad. Find the line "Implementation-version: 4.0.0 (b2)" and either delete the entire line or edit it to read "Implementation-version: 4.0.0". Save and exit Notepad and 7-Zip should ask if you want to update the archive - which you do.
Attachments
Last edited: