jsj_Delphi 插件创建

  • 格式:pdf
  • 大小:321.06 KB
  • 文档页数:12

one-sided
--
Delphi
Tlist
Tlist
TList
TCP/IP TclientSocket onRead
Hale Waihona Puke WindowsWM_GETMINMAXSINFO
TList initialization lstMinMax Windows WM_GETMINMAXINFO 9 { WM_GETMINMAXINFO. . } procedure TfrmMain.MinMaxInfo(var msg: TMessage); var m: PMinMaxInfo; i: Integer; begin file:// Windows.pas . m := pointer(msg.Lparam); for i := 0 to lstMinMax.count -1 do begin TResizeProc (lstMinMax[i])(m.ptMinTrackSize.x, m.ptMinTrackSize.y); end; end; 9: WM_GETMINMAXINFO LoadPlugin TList 10 LoadPlugin { DLL. } procedure TfrmMain.LoadPlugin(sr: TSearchRec); var Description: LibHandle: string; Integer; DescribeProc: TPluginDescribe; InitProc: InitEvents: begin LibHandle := LoadLibrary(Pchar()); if LibHandle
(Description); memPlugins.Lines.Add (Description); end else begin MessageDlg (’File "’ + + ’" is not a valid plug-in.’, mtInformation, [mbOK], 0); end; end else MessageDlg(’An error occurred loading the plug-in "’ + + ’".’, mtError, [mbOK], 0); end; LoadPlugin DLL LoadLibrary API DLL API GetProcAddress DescribePlugin cPLUGIN_DESCRIBE GetProcAddress GetProcAddree Assigned DLL nil
<> 0 then begin // DescribePlugin. DescribeProc := GetProcAddress(LibHandle, cPLUGIN_DESCRIBE); TPluginInit; TInitPluginEvents; if Assigned(DescribeProc) then begin // DescribePlugin. DescribeProc (Description); memPlugins.Lines.Add InitPlugin. (Description); file:// InitProc := GetProcAddress(LibHandle, cPLUGIN_INIT); if Assigned(InitProc) then begin file:// InitPlugin. InitProc (mnuMain); end; // InitPluginEvents InitEvents := GetProcAddress(LibHandle, cPLUGIN_INITEVENTS); if Assigned (InitEvents) then begin // InitPlugin. InitEvents(lstMinMax); end; end else begin MessageDlg('File "' + + '" is not a valid plugin.', mtInformation, [mbOK], 0); end; end else begin MessageDlg('An error occurred loading the plugin "' + + '".', mtInformation, [mbOK], 0); end; end;
GetProcAddress LoadPlugin InitPlugin DescribePlugin InitPlugin InitPlugin
assigned
8 InitPlugin main.pas unit main; interface uses Dialogs, Menus; type THolder = class public procedure ClickHandler(Sender: TObject); end; procedure DescribePlugin(var Desc: string); export; stdcall; procedure InitPlugin(ParentMenu: TMainMenu); export; stdcall; var Holder: THolder; implementation procedure DescribePlugin(var Desc: string); begin Desc := 'Test plugin 2 Menu test'; end; procedure InitPlugin(ParentMenu: TMainMenu); var i: TMenuItem; begin // . i := NewItem('Plugin &Test', scNone, False, True, Holder.ClickHandler, 0, 'mnuTest'); ParentMenu.Items[1].Add(i); end;
procedure THolder.ClickHandler; begin ShowMessage('Clicked!'); end; initialization Holder := THolder.Create; finalization Holder.Free; end. 8 InitPlugin exports NewItem TmenuItem ParentMenu.Items[1].Add(I); Items[1] Plug-in Plugin Plug-in Test NewItem TNotifyEvent export
DLL
Delphi IDE
uses
Sharemen
4 uses Sharemem, SysUtils, Classes, main in ’main.pas’; {$E plg.} exports DescribePlugin; begin end. DLL .DLL
*.plg $X Project Options
Delphi
LoadPlugins FormCreate FindFirst FindNext
2 3
LoadPlugins { } procedure TfrmMain.LoadPlugins; var sr: TSearchRec; path: string; Found: Integer; begin path := ExtractFilePath(Application.Exename); try Found := FindFirst(path + cPLUGIN_MASK, 0, sr); while Found = 0 do begin LoadPlugin (sr); Found := FindNext(sr); end; finally FindClose(sr); end; end; DLL. } procedure { TfrmMain.LoadPlugin(sr: TSearchRec); var Description: string; LibHandle: Integer; DescribeProc: TPluginDescribe; begin LibHandle := LoadLibrary(Pchar()); if LibHandle $#@60;$#@62; 0 then begin DescribeProc := GetProcAddress(LibHandle, cPLUGIN_DESCRIBE); if Assigned (DescribeProc) then begin DescribeProc
Delphi 2000-10-08 MiracleZdelphi Adobe Photoshop
DLL
DLL Photoshop
Report Smith QuickReport 怨怨 Rebuild DLL
3 DLL 1
怨怨
uses Sharemem DLL Sharemem DelphiMM.dll path ? DelphiMM.dll Delphi\Bin
Delphi Tholder ClickHandler Holder main.pas var Tholder initialization Holder.ClickHandler ClickHandler "Clicked!" NewItem
DLL
finalization Finalization initialization initialization finalization Holder.Free finalization Holder InitPlugin List boxes canvas tree views
DLL
GetProcAddress DescribeProc TpluginDescribe type TPluginDescribe = procedure(var Desc: string); stdcall; DLL stdcall var