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.
Post Reply
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

PROJECT: MultiEx Plugin Support

Post by Rahly »

Thought I'd make a topic for this too, "code submission" is a little vague.

Ok, working on the Plugin Manager (the glue between Mexcom and the Plugins)

Code: Select all

// To Get the manager version (Not ment for bug fixes, but for interface version, ie if functions or data past changes
function GetManagerVersion(var Major, Minor: Integer): Boolean; stdcall;

// To Get the supported interface version
function GetSupportedInterfaceVersion(var Major, Minor: Integer): Boolean; stdcall;

// Allows the calling process to select the directory of the plugins
//    This way multiex can store the plugin path whereever it wants
//    Should always be called once
function SetPluginDirectory(Directory: PChar): Boolean; stdcall;

// This refreshes the plugin list, also must be called to load for the first time too
function RefeshPluginList(): Boolean; stdcall;

function PluginCount(): Integer; stdcall;

function PluginInfo(Index: Integer; var PluginInfo: TPluginInfo): Boolean; stdcall;

// TPluginInfo so far is defined as
type
  TPluginInfo = packed record
    Size: Integer;
    PluginName: PChar;     // Module Name (to be displayed)
    PluginFullPath: PChar;  // Full path to the plugin module
    VersionMajor, VersionMinor: Integer;
    InterfaceMajor, InterfaceMinor: Integer;
    Supported: Boolean;    // This allows us to show Unsupported plugins in the list
  end;
This information is mainly ment for display purposes to a user. And Except for GetManagerVersion, should not be USED in coding. The plugin manager will handle all supported and unsupported versions automatically. This also lets plugin developers see what mexcom's plugin manager sees.
"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 »

Mr. Mouse, also, feel free to voice your opinions and/or ideas. Maybe something you want mexcom to do or to provide. :-D
"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 most certainly will! :D
There's been some criticism on the Painkiller.dll, and one thing that bugs me is that the Commander can't yet create these pak files from scratch.
I will have to find time to implement stuff like that, but before I can, the Plugin Manager will have to be operational. There's no rush, by the way, this is not a push! Take your time, it's best to have something good, that took some time eh. 8)
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Yeah, we have a saying at work "Good, Fast, Cheap. Pick any 2".

Good and Fast = Not Cheap
Good and Cheap = Not Fast
Cheap and Fast = Not Good

:-D
"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 »

Mr. Mouse, can you make me 2 vb programs for testing.

Something really simple

Program 1:

Create a program with 3 buttons on it,
1) imports a function from "test.dll" called "TestFunction1" and calls it. Function has a parameter of a String returns a Long/Integer.
2) imports a function from "test.dll" called "TestFunction2" and calls it. Function has a parameter of an array of long/integer, returns a long/integer.
3) imports a function from "test.dll" called "TestFunction3" and calls it. Function has a parameter of an array of string, returns a long/integer.

Program 2:

Create a program with 3 buttons on it,
1) import a function from "testcall.dll" called "TestFunction1" and calls it. Function has a parameter of a pointer/reference to a function that takes a paramter of a string and returns a long/integer.
2) imports a function from "test.dll" called "TestFunction2" and calls it. Function has a parameter of a pointer/reference to a function has a parameter of an array of long/integer, returns a long/integer.
3) imports a function from "test.dll" called "TestFunction3" and calls it. Function has a parameter of a pointer/reference to a function has a parameter of an array of string, returns a long/integer.

Thx for your time.

This is for me to see how VB6 passes data back and forth between DLLs, and to see how i can make VB6 call backs. Esp with strings and arrays.
"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'll see what I can do on short notice. I'm @work at the mo', so it will have to wait until I get home, and have time there. Pleasing the mrs. and raising the dog can be quite time-consuming, let alone a bunch of other hobby chores that await me. :D
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Np, i didn't mean this instant. Oh yeah, call called programs use the standard API calling method, incase you need 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 »

Rahly wrote:Np, i didn't mean this instant. Oh yeah, call called programs use the standard API calling method, incase you need that.
Ok!
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:Mr. Mouse, can you make me 2 vb programs for testing.

Something really simple

Program 1:

Create a program with 3 buttons on it,
1) imports a function from "test.dll" called "TestFunction1" and calls it. Function has a parameter of a String returns a Long/Integer.
2) imports a function from "test.dll" called "TestFunction2" and calls it. Function has a parameter of an array of long/integer, returns a long/integer.
3) imports a function from "test.dll" called "TestFunction3" and calls it. Function has a parameter of an array of string, returns a long/integer.

Program 2:

Create a program with 3 buttons on it,
1) import a function from "testcall.dll" called "TestFunction1" and calls it. Function has a parameter of a pointer/reference to a function that takes a paramter of a string and returns a long/integer.
2) imports a function from "test.dll" called "TestFunction2" and calls it. Function has a parameter of a pointer/reference to a function has a parameter of an array of long/integer, returns a long/integer.
3) imports a function from "test.dll" called "TestFunction3" and calls it. Function has a parameter of a pointer/reference to a function has a parameter of an array of string, returns a long/integer.

Thx for your time.

This is for me to see how VB6 passes data back and forth between DLLs, and to see how i can make VB6 call backs. Esp with strings and arrays.
Can you also give me the test.dll? Or should I create one. I must make sure the program does what it is supposed to do.

Though you can just try these, scroll down for the download:
testapp1 wrote: MODULE :
Public Declare Function TestFunction1 Lib "test.dll" (ByVal str As String) As Long
Public Declare Function TestFunction2 Lib "test.dll" (ByRef arrLong() As Long) As Long
Public Declare Function TestFunction3 Lib "test.dll" (ByRef arrStr() As String) As Long

FORM:
Private Sub Command1_Click()
'Call
Dim John As Long
John = TestFunction1("ZuurmanRulez")
End Sub


Private Sub Command2_Click()
'Call
Dim Anita As Long
Dim John() As Long
ReDim John(10)
John(0) = 15
John(1) = 255
John(2) = 1023

Anita = TestFunction2(John)
End Sub


Private Sub Command3_Click()
'Call
Dim John As Long
Dim You() As String
ReDim You(10)
You(0) = "Mike"
You(1) = "Zuurman"
You(2) = "Was"
You(3) = "Here"
John = TestFunction3(You)
End Sub
testapp2 wrote: Public Declare Function TestFunction1 Lib "testcall.dll" (ByVal ptrFunc As Long) As Long
Public Declare Function TestFunction2 Lib "testcall.dll" (ByVal ptrFunc As Long) As Long
Public Declare Function TestFunction3 Lib "testcall.dll" (ByVal ptrFunc As Long) As Long


Public Function myFunc(str As String) As Long

myFunc = Len(str)
End Function

Public Function myFunc2(arrLong() As Long) As Long

myFunc2 = UBound(arrLong)
End Function

Public Function myFunc3(arrStr() As String) As Long

myFunc3 = UBound(arrStr)
End Function

Public Sub Command1_Clicked()
'Call
Dim John As Long
John = TestFunction1(AddressOf myFunc)
End Sub


Public Sub Command2_Clicked()
'Call
Dim Anita As Long

Anita = TestFunction2(AddressOf myFunc2)

End Sub


Public Sub Command3_Clicked()
'Call
Dim Anita As Long

Anita = TestFunction3(AddressOf myFunc3)
End Sub
You do not have the required permissions to view the files attached to this post.
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Thanks, the first program works great. I need to write the DLL for the second one. I just wanted to see how VB passed Strings and Arrays to functions. I had thought that it passed strings as PWideChars which is the native strings in VB, but it infact converts them PChars using OLE automation. Now i need to find how how to call a function :-D
"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 »

decided to remove GetVersion from the plugin, replaced it will GetPluginInfo(var PluginInfo: TPluginInfo);

Code: Select all

  TPluginInfo = packed record
    // Version 1.0
    Size: Integer;
    Name: PChar;
    Author: PChar;
    Major: Integer;
    Minor: Integer;
  end;
  
function mpGetPluginInfo(var Info: TPluginInfo): Boolean; stdcall;
This allows information such as a plugin name and the name of the author, All information this function provides is for display or informational purposes only, and my no means, should be used in conditional coding, use the Interface Version number for conditional testing.
"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 »

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
var
  Count: Integer;
  MyPlugInfo: TPluginInfo;
  MyStr: String;
begin
  ListBox1.Items.Clear;
  RefreshPluginList();
  ListBox1.Items.Clear;
  For Count := 0 to PluginCount()-1 do
    begin
    MyPlugInfo.Size := SizeOf(MyPlugInfo);
    if PluginInfo(Count, MyPlugInfo) then
      begin
      MyStr := String(MyPlugInfo.PluginName) + ' (' + ExtractFilename(String(MyPlugInfo.PluginFullPath)) + ' ' + IntToStr(MyPlugInfo.VersionMajor) + '.' + IntToStr(MyPlugInfo.VersionMinor) + ') by '+ MyPlugInfo.PluginAuthor;
      if Not(MyPlugInfo.Supported) then
        MyStr := MyStr + ' (Not Supported)';
      ListBox1.Items.Add( MyStr );
      end;
    end;
end;
Sample code for getting plugin information and showing the user. See attached picture. This procedure is the code for the "Refresh" button.

Also, i'm thinking of adding, in the plugin, a URL and email field. Possibly for support reasons of the plugin.
You do not have the required permissions to view the files attached to this post.
"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 »

Looking good! :D
Rahly
VVIP member
VVIP member
Posts: 412
Joined: Thu Aug 05, 2004 10:17 am
Been thanked: 1 time

Post by Rahly »

Current I have plugin information completed. Here is the manager dll with the ability to get a list of plugins and plugin information, if you wanna test it, or start that functionality in mexcom. You can bind statically to this dll.

How it should work.

On startup

1. mexcom calls GetManagerVersion to get the version of the manager dll, alert the user if its not the version your looking for and exit OR ignore, continue if its the right version

2. call SetPluginDirectory to set the path for the plugins for the manager to use

3. call RefreshPluginList to find all available plugins (Initial Plugin Load)

Where you want to display a list of the plugins

1. Call PluginCount to get a count of plugins

2. Call PluginInfo with an index of 0 to (PluginCount-1) to get information for a plugin.

Whenever you want to refresh the a list of the plugins call RefreshPluginList.
"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 »

Didn't post the file GRRR.

Common.pas is a file with all the common types and constants.

Unit3.pas is a sample file of imported static functions from PluginManager.dll

PluginManager.dll is the plugin manager(if you couldn't guess :))

BFFileFormat.mxp is a good plugin (supported)

Unsupported.mxp is a bad plugin (unsupported)
"By nature men are alike. Through practice they have become far apart." Confucius (Analect 17:2)
Post Reply