• Welcome to Jose's Read Only Forum 2023.
 

How to write c++ to call a PB dll

Started by Chris Chancellor, August 21, 2018, 07:32:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Chancellor

Hello all

i'm looking for a c++ code that can call a PB dll and retrive a string from that PB dll.

how to write this c++ code ?

all help appreciated and thanxx in advance

Patrice Terrier

The easiest way is to export your strings as ASCIIZ.

But if you link with a PB DLL, then you are limiting yourself to 32-bit only.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Chris Chancellor

Thanxx Patrice

i'm doing the conversion to C++ stage by stage, something like testing the water first
before leaping into it.  The main thing is to shed the PB codes or modules whenever i find a better
replacement for it.

so do you have any codes in C++ and PB that i can test out ?

Patrice Terrier

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Frederick J. Harris

Quote
i'm looking for a c++ code that can call a PB dll and retrive a string from that PB dll.

Everything depends on what you mean by retrieve 'a string'.  Most PB'ers use PowerBASIC's Dynamic String Type, i.e., String or WString.  The underlying machinery involved in that is the COM based BSTR data type, which is actually a very simple class.  I would assume if you have a PowerBASIC dll containing one or more functions which take as a parameter a String as described above, then you are going to get yourself into C/C++ 'deep water' very fast, as you are going to have to master some fairly advanced C++ topics including C++ low level COM and the nuances of the BSTR type. 

If you are just starting out with C++ your best bet is to do as Patrice says and rework your PowerBASIC dll to use null terminated strings (asciiz or wstringz).  Having done that, using a C/C++ host/client, the incomming string will simply be interpreted as a pointer to a string of characters - something a beginning C/C++ coder can easily deal with.  Hope this helps.  In my various tutorials I give a number of simple examples of this.