The Forum is up for sale: XeNTaX Forum looking for new owner

PROJECT: MultiEx Plugin Support

Coders and would-be coders alike, this is the place to talk about programming.
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

do you want a WORKING delphi application? or how it SHOULD work for you, but in delphi?

I have talored the Manager to work with VB, and because of VB crazy dll talking, i've had to do some special. So if i wrote a working application, it would do have to do some cleanup, that VB does automatically and stuff like that.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 680 times
Contact:

Post by Mr.Mouse »

I guess it's just all the new manager source (functions, declares, consts) etc.

No need to rewrite it ;)
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Code: Select all

// Plugin Support Information

function GetManagerVersion(var Major, Minor: LongInt): LongBool; stdcall;
function GetSupportedInterfaceVersion(var Major, Minor: LongInt): LongBool; stdcall;
function SetPluginDirectory(Directory: PChar): LongBool; stdcall;
function RefreshPluginList(): LongBool; stdcall;
function PluginCount(): LongInt; stdcall;
function PluginInfo(Index: LongInt; var MyPluginInfo: TManagerPluginInfo): LongBool; stdcall;
function FreeCache():LongBool; stdcall;
function SetCacheSize(Size: LongInt):LongBool; stdcall;

// Plugin Calls

function mpGetFormatCount(): LongWord; stdcall;
function mpGetFormatInfo(FormatIndex: LongInt; var FormatInfo: TFormatInfo): LongBool; stdcall;
function mpGetOptions(FormatIndex: LongInt; OptionType: LongInt): PChar; stdcall;
function mpSetOption(FormatIndex: LongInt; OptionType: LongInt; Name: PChar; Value: PChar): LongBool; stdcall;
function mpOpenArchive(var ArchiveHandle: LongInt; FormatIndex: LongInt; ArchiveName: PChar; Flags: Cardinal): LongBool; stdcall;
function mpOpenArchiveBindStream(var ArchiveHandle: LongInt; FormatIndex: LongInt; Stream: IStream; Flags: Cardinal): LongBool; stdcall;
function mpCloseArchive(FormatIndex: LongInt; ArchiveHandle: LongInt): LongBool; stdcall;
function mpIndexCount(FormatIndex: LongInt; ArchiveHandle: LongInt): LongInt; stdcall;
function mpIndexedInfo(FormatIndex: LongInt; ArchiveHandle: LongInt; Index: LongInt; Item: PChar): PChar; stdcall;
function mpFindInfo(FormatIndex: LongInt; Handle: LongInt; Field: PChar): PChar; stdcall;
function mpFindFirstFile(FormatIndex: LongInt; ArchiveHandle: LongInt; FileMask: PChar): LongInt; stdcall;
function mpFindNextFile(FormatIndex: LongInt; FindHandle: LongInt): LongBool; stdcall;
function mpFindClose(FormatIndex: LongInt; FindHandle: LongInt): LongBool; stdcall;
function mpIsFileAnArchive(FormatIndex: LongInt; Filename: PChar): LongBool; stdcall;
function mpIsStreamAnArchive(FormatIndex: LongInt; Stream: IStream): LongBool; stdcall;
function mpExportFileByNameToFile(FormatIndex: LongInt; ArchiveHandle: LongInt; ArchiveFile: PChar; ExternalFile: PChar): LongBool; stdcall;
function mpExportFileByIndexToFile(FormatIndex: LongInt; ArchiveHandle: LongInt; FileIndex: LongInt; ExternalFile: PChar): LongBool; stdcall;
function mpExportFileByNameToStream(FormatIndex: LongInt; ArchiveHandle: LongInt; ArchiveFile: PChar; Stream: IStream): LongBool; stdcall;
function mpExportFileByIndexToStream(FormatIndex: LongInt; ArchiveHandle: LongInt; FileIndex: LongInt; Stream: IStream): LongBool; stdcall;
function mpImportFileFromFile(FormatIndex: LongInt; ArchiveHandle: LongInt; ArchiveFile: PChar; ExternalFile: PChar): LongBool; stdcall;
function mpImportFileFromStream(FormatIndex: LongInt; ArchiveHandle: LongInt; ArchiveFile: PChar; Stream: IStream): LongBool; stdcall;
function mpRemoveFileByName(FormatIndex: LongInt; ArchiveHandle: LongInt; Filename: PChar): LongBool; stdcall;
function mpRemoveFileByIndex(FormatIndex: LongInt; ArchiveHandle: LongInt; FileIndex: LongInt): LongBool; stdcall;
function mpGetLastError(FormatIndex: LongInt): Cardinal; stdcall;
function mpGetErrorText(FormatIndex: LongInt; Value: Cardinal): PChar; stdcall;
that it?
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Saw this, didn't know if maybe you wanted to read it.

http://www.vbaccelerator.com/home/VB/Ty ... rticle.asp
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 680 times
Contact:

Post by Mr.Mouse »

Rahly wrote:Saw this, didn't know if maybe you wanted to read it.

http://www.vbaccelerator.com/home/VB/Ty ... rticle.asp
Ah yes, something like that may come in handy in the future.
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Hey, i'm also looking at the prospect of binding with explorer, similar to how ZIP files are implemented in XP.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Example

Image

this binds .fpk archives (from Sid Meier's Pirates!) with explorer.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 680 times
Contact:

Post by Mr.Mouse »

That is nice stuff.:)
Captain
Site Admin
Posts: 249
Joined: Wed Jan 15, 2003 6:25 pm
Location: Home
Has thanked: 2 times
Been thanked: 61 times
Contact:

Post by Captain »

Awesome!
Neko
n00b
Posts: 12
Joined: Mon Aug 29, 2005 11:35 am
Location: The Netherlands
Contact:

Post by Neko »

Are there any examples of a Delphi plug-in or plug-in manager?
I want to make one.
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

it was just released this week, i haven't had time to finish the documentation yet. nor have i finished the C/C++ header files for generating a plugin.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Neko
n00b
Posts: 12
Joined: Mon Aug 29, 2005 11:35 am
Location: The Netherlands
Contact:

Post by Neko »

Can you send me a copy of the current Common.pas and the list of mp* function definitions? I don't know if the ones in this topic are still current and wouldn't want to get it wrong.
Neko
n00b
Posts: 12
Joined: Mon Aug 29, 2005 11:35 am
Location: The Netherlands
Contact:

Post by Neko »

On the current API: it might be possible to change the PChar arguments to WideString. That would make it not reference counted and prevent certain problems. Visual Basic will just take it... but I cannot easily check.

Returning strings (PChar) in DLL functions (also WideStrings) generally leads to problems. Do these functions work right now?
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

I'll have a plugin skeleton shortly, PChars are not referenced counted, AnsiStrings are.

And VB Doesn't take it. ByVal Value as String <--- VB converts a UTF-16 String to an Ansi String. I'm trying to see if i can find a better way to get WideStrings, as I would like to have that implemented in a later version.

MrMouse and I have spend a few hours just getting strings to work. PChar is what the plugins use as its easy for a C/C++ pluging to make a char* and delphi already has support (PChar). The plugin manager itself acts as a buffer between MexCom and the Plugins. There are a few reasons that make VB a terrible language to implement plugins in.
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Neko
n00b
Posts: 12
Joined: Mon Aug 29, 2005 11:35 am
Location: The Netherlands
Contact:

Post by Neko »

Rahly wrote: MrMouse and I have spend a few hours just getting strings to work. PChar is what the plugins use as its easy for a C/C++ pluging to make a char* and delphi already has support (PChar). The plugin manager itself acts as a buffer between MexCom and the Plugins. There are a few reasons that make VB a terrible language to implement plugins in.
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.
Post Reply