お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"プラグインインターフェースを作る"





 DLLの側からEXE側の関数を呼び出すサンプルです。EXE側の関数を強化
して行けばプラグインインターフェースが作れる事でしょう。

.EXE側ソース----------------------------------------------------------
program PlugExe;

uses Windows;

type
    TPlugInterface = function(ExeProcAddress: Pointer):LongInt;stdcall;

function ExeInterface(Msg: pChar):LongInt;stdcall;
begin
     Result:= MessageBox(0, Msg, 'TEST',MB_YESNOCANCEL);
end;

var
   PlugInterface: TPlugInterface;
   hDll: THandle;
begin
     hDll:= LoadLibrary('plugdll');
     if hDll=0 then
     begin
          MessageBox(0,'LoadLibrary Error!!','Error',MB_ICONSTOP or MB_OK);
          exit;
     end;
     
     try
        @PlugInterface:= GetProcAddress(hDll, 'PlugInterface');
        PlugInterface(@ExeInterface);
     finally
        FreeLibrary(hDll);
     end;
end.

.DLL側ソース----------------------------------------------------------

library PlugDll;

uses Windows;

type
    TExeInterface = function(Msg: pChar):LongInt;stdcall;

function PlugInterface(ExeProcAddress: Pointer):LongInt;stdcall;export;
var
   ExeInterface: TExeInterface;
begin
     @ExeInterface:= ExeProcAddress;
     ExeInterface('Yes? No? Cancel?');
end;

exports
  PlugInterface;

begin
end.

----------------------------------------------------------------------
                               折井 哲
                               VZX00324


Original document by 折井 哲        氏 ID:(VZX00324)


ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum