Тема: Як ззвоні викликати DoAction плагіну Download master?

Код з файлу dmtest_plugin.dpr. Файл проекту:

library dmtest_plugin;

uses
  ShareMem,
  SysUtils,
  Classes,
  dmtest_pluginImpl in 'dmtest_pluginImpl.pas',
  DMPluginIntf in 'DMPluginIntf.pas';

var
 //обʼєкт плагіну
  e: TDMTestPlugIn;
{$R *.res}
function RegisterPlugIn: IDMPlugIn; stdcall;
begin
  try
    e := TDMTestPlugIn.Create;
    Result := e as IDMPlugIn;
    //Result := TDMTestPlugIn.Create;
  except
    Result := nil;
  end;
end;

//Моя процедура
procedure StartDownload(url, save: PWideChar); stdcall;
begin
  e.creare_new_download(UTF8Encode(WideString(url)), UTF8Encode(WideString(save)));
end;

exports RegisterPlugIn;
exports StartDownload;

begin
end.

Код з файлу dmtest_pluginImpl.pas. Реалізація плагіну.

unit dmtest_pluginImpl;

interface

uses DMPluginIntf, Classes, Dialogs;

type
TDMTestPlugIn = class(TInterfacedObject, IDMPlugIn)
  public
    myIDmInterface: IDmInterface;

    procedure PluginInit(_IDmInterface: IDmInterface); stdcall;
    procedure creare_new_download(url, save: WideString); stdcall
end;

implementation


procedure TDMTestPlugIn.PluginInit(_IDmInterface: IDmInterface);//ініціалізія плагіну і передача інтерфейсу для доступу до DM
begin
  myIDmInterface := _IDmInterface;
end;

procedure TDMTestPlugIn.creare_new_download(url, save: WideString); stdcall;
begin
  myIDmInterface.DoAction('AddingURL', '<url>http://www.westbyte.com/plugin</url> <sectionslimit>2</sectionslimit>');
end;
end.

Файл DMPluginIntf.pas. Інтерфейс плагіну:

unit DMPluginIntf;

interface

type
  { IDMInterface }
  IDMInterface = interface(IUnknown)
  ['{B412B405-0578-4B99-BB06-368CDA0B2F8C}']
    function DoAction(action: WideString; parameters: WideString): WideString; stdcall;
  end;

  { IDMPlugIn }
  IDMPlugIn = interface(IUnknown)
  ['{959CD0D3-83FD-40F7-A75A-E5C6500B58DF}']
    function getID: WideString; stdcall;
    //-----info
    function GetName: WideString; stdcall;
    function GetVersion: WideString; stdcall;
    function GetDescription(language: WideString): WideString; stdcall;
    function GetEmail: WideString; stdcall;
    function GetHomepage: WideString; stdcall;
    function GetCopyright: WideString; stdcall;
    function GetMinAppVersion: WideString; stdcall;

    //------
    procedure PluginInit(_IDmInterface: IDmInterface); stdcall;
    procedure PluginConfigure(params: WideString); stdcall;
    procedure BeforeUnload; stdcall;

    function EventRaised(eventType: WideString; eventData: WideString): WideString; stdcall;
    property ID: WideString read getID;
  end;

implementation

end.

Виклик з VB.NET:

<Runtime.InteropServices.DllImport("C:\Program Files\Download Master\Plugins\dmtest_plugin.dll", SetLastError:=True, CharSet:=Runtime.InteropServices.CharSet.Unicode, CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall)> _
Public Sub StartDownload(ByVal url$, ByVal save$)
End Sub

Sub Main()
  StartDownload("http://myurl", "c:\dadas.exe")
  Console.ReadKey()
End Sub

Помилка:

AccessViolationException was unhandled. Attempt to read or write protected memory.