Page 17 of 20

Posted: Thu Sep 01, 2005 1:23 am
by Rahly
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):

Code: Select all

  function PlugInVersions(Path: PChar; BufferSize: Integer; var Buffer: PChar): Integer; stdcall; forward;
(returning string length as function result).

Code: Select all

  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:

Code: Select all

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.

Posted: Thu Sep 01, 2005 1:33 am
by Rahly
oh and again, the manager handles all this, doesn't matter what the plugin does.

Posted: Thu Sep 01, 2005 8:43 am
by Mr.Mouse
I recently noticed a function in VB that would convert UNICODE strings. The problem is that this stuff is not possible in dll-calls.

Posted: Tue Sep 06, 2005 6:47 am
by Rahly
Skeleton plugin for delphi is done, I'll be releasing it the same time i've finished updating the BF plugin.

Posted: Tue Sep 06, 2005 7:23 am
by Mr.Mouse
Awesome!

Posted: Wed Sep 07, 2005 3:26 am
by Rahly
This is kinda better, now i have a final product to work with :-D

I'm already thinking of new ideas for the new one

Posted: Wed Sep 07, 2005 4:52 am
by Rahly
Small problem,

BF plugin only supports the OPENFLAG_FOREXPORT

if the plugin doesn't have SUPPORTFLAG_CREATE, then OPENFLAG_CREATENEW and OPENFLAG_OPENALWAYS shouldn't be passed, as CREATENEW OPENALWAYS

CREATENEW = overwrite file with a new archive
OPENALWAYS = if archive file doesn't exist create a new one

Posted: Wed Sep 07, 2005 8:06 am
by Mr.Mouse
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.

Posted: Wed Sep 07, 2005 11:31 am
by Rahly
I thought we fixed that, and I sent you another version.

Posted: Wed Sep 07, 2005 12:05 pm
by Mr.Mouse
Interesting. Anyway. A new version is easily released, this is just small fix. I will take care of that.

Posted: Wed Sep 07, 2005 12:16 pm
by Rahly
wait a min on that, i have to check something else out too.

Posted: Wed Sep 07, 2005 12:25 pm
by Mr.Mouse
Ok

Posted: Wed Sep 07, 2005 12:38 pm
by Rahly
screens of the BF plugin

Image
Image

Exports good as well

Posted: Wed Sep 07, 2005 12:40 pm
by Mr.Mouse
W00t!! :D :D

Posted: Wed Sep 07, 2005 12:49 pm
by Rahly
what do you mpGetOptions() for when you startup?