I have to create a DLL in Delphi, which is used as API for a Windows NT-Service (also Delphi). The Client-Program which is going to use this DLL will written in Visual Basic 6.0
Now I have some Questions on the Compatibility. The last few Days I was reading Articles in MSDN and TechNet about technical Issues of Visual Basic and I've found compatible Data-Types for the most numeric Types we are going to use.
But what I'm not sure about are the Strings. I know I'll have to use pChar to avoid Problems with Delphi's String Memory Managment.
But how could a Function look like, which returns a pChar with variable Lenght are takes/gives a pChar as Parameter ?
I read in technical Docs, that VB creates a temporary copy of the string declared by the VB-Programmer in the format of the C-Language, so it's a null-terminated pChar and passes the DLL-Function a Pointer to it.
Therefore, i should be able to implement the string-support just like the API does.
could it be something like this ?
function ReturnStr(var AvaiableByteFromHostApp, RequiredBytesByDLL : Integer) : pChar;
function GetString(var Buffer : pChar) : Integer;
here the function result would be the length of the string, the Functions are delcared as stdcall...of course :)
Another Thing is, do I need to include the ShareMem-Unit and publish the DLL with the BorlandMM.DLL (which i dont want) also, if i use just Delphi-Strings internally in the DLL and convert them into pChars whenever they are exported from the DLL, or would that not affect the entire thing ?