How do I call Pb the generated Win32 native DLL from .Net? Or somewhere else?

I was trying to link Pb (11.5) with native Win32 DLLs: both from another Pb application and from a .net (2.0) application. I know registered COM objects are visible to Pb. What I want to do is have the Pb call functions (11.5 Enterprise running) in a native Win32 DLL - not COM. I also want to go the other way: I want the Win32 exe (both native and .net) to call a function in the DLL generated by Pb. I have had limited success.

Scenario 1: Pb generates native Win32 exe and dll.

I created a simple application that includes a separate pbl (called shared.pbl) with some trivial functionality (including one that returns the HelloWorld string). The project is built on an exe and a separate dll. It works (button click shows HelloWorld text in label).

In a separate Pb workspace, I create an almost identical application, but not shared.pbl. I declare an external function to reference shared.dll from the first workspace:

 function int GetSystemMetrics( int index ) library "user32.dll";
 function int f_rtn_int( int number ) library "shared.dll";

      

launching the application - clicking the button bound to GetSystemMetrics () works. Clicking the second button to access the shared.dll file fails with the message "External function call failed ...".

The only way I was able to get the second application running was by adding shared.dll in the target properties libraries list tab. However, it looks like the contents of the DLL will be embedded in the generated exe - I can delete shared.dll and the second application works fine!

How to reference an external Win32 DLL in Pb without having an embedded DLL in the generated Pb code? Remember shared.dll was generated by Pb in a separate workspace.

Scenario 2: .Net exe accesses the generated Pb dll

Then I created a simple .net application (.net v2.0, vs2005) with parallel functionality for Pb applications. I am referencing shared.dll:

  [DllImport( "user32.dll" )]
  static extern int GetSystemMetrics( int smIndex );
  [DllImport( "shared.dll" )]
  static extern string f_get_hello_world();

      

and try calling the HelloWorld function and I get a .net error:

 Unable to find an entry point named 'f_get_hello_world' in DLL 'shared.dll'

      

Using editor / dissasembler, I find that the function name is mangled into "_getVtableInfo_f_get_hello_world @ 12". I've tried different naming options for the ad and called with no luck.

Is it possible to reference a native Win32 DLL built by Pb from another language (C ++, C #)? If so, how?

0


source to share


2 answers


Basically, you don't. You can create a COM object project, or from 11 or 11.5 you can create a .NET assembly. The native generation DLLs are not standard Windows DLLs, so they cannot be called using regular DLL methods.

Good luck,



Terry.

+2


source


If Pb obeys "extern C" in your function definitions, then it should export them with unconnected names.



For your other question about why it seems that the DLL is uninstalled and the program is still running, I can only give a little possible guess: see if any tool failed to make another copy of the DLL and it still exists.

0


source







All Articles