🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by ���ܵ�Сʨ Thu, 07 May 1998 00:00
����Delphi������ʹ�ö�̬���ӿ�
#866
Author: ���ܵ�Сʨ
Date: Thu, 07 May 1998 00:00
97 lines
5704 bytes
   ��̬���ӿ�(DLL)��Windows������Ҫ�IJ���֮һ,Windows�е���
�г�����Թ���DLL�е������,�Ӷ�ʹӦ�ó�����Թ������,����
�ڴ�ռ�á����ļ�Ҫ������Delphi������ʹ��DLL��

    һ��������̬���ӿ�

    1.����һ���µĹ����ļ�
    ���ڴ˹���ֻ�Ǹ����ļ�,��˲�����ҪForm������ѡ�����˵�V
iew|Project Manage, ���Զ���ɵ�Unit1��Form1��ȥ,Ȼ��ѡ��Fil
e|Save Project As,���˹���ȡ��Ϊ Mydl.d pr����(��������� ),
 ��ϵͳ�����Ƿ񱣴�Unit1ʱ�ش�NO��,��ѡ��View|Projectourc 
e,��������޸�����:
    library  Mydll;
      uses   WinTypes;
      begin
      end.
    ���ļ���һ�㹤���ļ���Ҫ��֮ͬ�����ڽ���ʶ��"program"��
Ϊ"library"��
    2.��̬���ӿ��м��뱻���Ӧ�ó����õ������(��̼���
�� )
    ����һ���µ�Unit,�������Ӧ�ó����õ����������������
��ʵ�֡�ע�������Ui t��Interface�������������β��Ҫ�ӹؼ�
��"export",��ʾ������ܹ���"���",Ҳ�����ܱ�����Ӧ�ó������
������:��һ�����ú���Plus,�������ǽ������������,��Unit�Ĵ�
������:
    Unit    Content; {������̵�Ԫ,���������}
    interface
    function  plus (a,b:integer):integer;export;
    implementation
    function  plus (a,b:integer):integer;
      begin
       Result:=a+b;
      end;
    end.

    3.����������
    ѡ��View|Project Source,��Mydll.dpr��uses����֮�����:
    exports
    plus; {������������}
    ����Ĺ����ļ�����:
    library  Mydll;
    uses    WinTypes,
            Content   in  ��CONTENT.PAS��;
    exports
     plus;
    begin
    end.
    ���Ͼ������DLL��Ĵ���,ѡ��Compile������롣
    ����ʹ�ö�̬���ӿ�
    DLL�е���Դ���Ա����EXE�ļ�����,���ڿ�����Delphi������
��Ӧ�ó���,��ͬʹ��y dll.dll�еĺ���Plus:

    1.����һ���µĹ����ļ� Usedll.dpr, ��ȥ���е�Unit��Form
��
    2.Ϊ���� Mydll.dll �еĺ���Plus,����һ���µ�Unit,��Ŀ��
��Ϊ��˵��Ҫ���õ���̴������ĸ�DLL����(�ùؼ���"external"),
��Unit�Ĵ�������:
    Unit  useunit;  {����ʹ��DLL�ĵ�Ԫ}
    interface
    function  plus (a,b:integer):integer;
    implementation
    function  plus; external ��Mydll��;
    {˵��������������ⲿMydll.dll����ʵ�ֵ�}
    end.
    ���Կ���,�����ⲿ���,��interface���ֵ���������ͨ���һ
��,������implementai on����Ҫʹ�ùؼ���"external",��ʾ�����
���ڳ����ⲿʵ�ֵġ�
    3.����Ҫʹ�ú���Plus��Unit��,ֻҪ����Implementation����
��Uses��useunit��������ɡ�
    ����:�½�һForm,����Edit��Button�ؼ�,ΪButton����OnClick
�¼�,��Form��ӦUni��implementation��������:
    implementation
      {$R *.DFM}
    uses useunit;     {��useunit��Ԫ}
      procedure TForm1.Button1Click(Sender: TObject);
      {Button1��OnClick�¼�}
    begin
      Edit1.Text:=IntToStr (Plus (10,20));
      {ʹ��DLL���еĺ���}
    end;
        end.
    ���˹��̱���,���Usedll.exe,����ʱ����Button���ɿ���Edit
�ؼ���Text�����30��
    ��������Խ������EXE�ļ�,��ͬʹ��Mydll�еĺ���Plus,�ɴ�
���Կ�����̬���ӿ����Խ��,�ر����ڿ����������ʱ,��̬���ӿ�
����ʹ�á�
    ���ϳ�����Delphi 1.0/Win3.2��Delphi2.0/Win95������ͨ��
--
 ________ _____          _____        ______________  _____ 
 ___  __ \___(_)________ ___(_)       __  ___/___  /_ ___(_)
 __  /_/ /__  / ___  __ \__  /        _____ \ __  __ \__  / 
 _  ____/ _  /  __  /_/ /_  /         ____/ / _  / / /_  /  
 /_/      /_/   _  .___/ /_/          /____/  /_/ /_/ /_/   
                /_/                                         

�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads