Neko wrote:I know, I've spend days on it in the past. And got it to work eventually. The 'correct' way to return a string (this is what I used anyway):
for i:=1 to Length(tmpDynaFile) do begin
Buffer[i-1]:=tmpDynaFile[i];
end;
Buffer[Length(tmpDynaFile)]:=#0;
Result:=Length(tmpDynaFile);
And this would return something. But note that this code does not check BufferSize, which is a requirement these days. Wouldn't want buffer overflows.
This is the corresponding VB declaration and code:
Private Declare Function PlugInVersions Lib "tibedhlp.dll" (ByVal Path As String, ByVal BufferLength As Long, BufferText As String) As Long
Function GetPluginLiveUpdateInfo() As String
Dim Buffer As String * 255
Dim q As Long
q = PlugInVersions(DataDir$, 255, Buffer)
GetPluginLiveUpdateInfo = Left$(Buffer, q)
End Function
Might be useful.
Too much work for Mr.Mouse better to just return a PChar thats compatible with VB. The main problem with VB is that if you return a string, vb tries to free that memory itself, so you CAN'T make memory with Delphi's memory manager or your fubar things there. In fact, windows gives you some GREAT functions to do it, as VB uses the same functions. Thereby, it simplifies my end as well as Mr.Mouse's end, doesn't worry about buffer overflows, can still use delphi strings internally, and it works via a single call where he doesn't have to write a wrapper. I had 3 goals in mind, multiple language support, ease for MrMouse to implement, and functionality.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Hmm. Allright, we can take a look at that. The problem was that your test plugin didn't work if I just used FOREXPORT, I HAD to give the other flags as well. We discussed this be email as well.