.


:




:

































 

 

 

 


Return 1;




}

//-------------------------------------------------------------------------

void Message(char *s)

{

i=10;

Application->MessageBox(s,"From DLL",IDOK);

}

P.h

#if defined(BUILD_DLL)

# define DLL_EXP __declspec(dllexport)

#else

# if defined(BUILD_APP)

# define DLL_EXP __declspec(dllimport)

# else

# define DLL_EXP

# endif

#endif

DLL_EXP void Message(char *s);

DLL_EXP int i;

.

Run ().

. (File / New Application) OnClick. :

//---------------------------------------------------------------------------

#include

#define BUILD_APP

#pragma hdrstop

#include "p.h"

#include "Unit1.h"

#include

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//-------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//-------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{char c[10];

Message("roma");

for(; i>0;i--)

{ sprintf(c,"Example %d",i);

Application->MessageBox("Example of using DLL variable",(char*)c,IDOK);

}

}

//-------------------------------------------------------------------------

. . .lib DLL( , ADD). .

, , DLL : DLL, .lib.

. DLL ( .lib , ).

, . DLL :

extern "C" void __export Message(char *s)

{

Application->MessageBox(s,"From DLL",IDOK);

}

C , DLL.

( OnClick) :(Unit11.cpp)

//---------------------------------------------------------------------------

#include

#pragma hdrstop

#include "Unit11.h"

#include

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

void (__stdcall *Message)(char *s);

HINSTANCE dllp = LoadLibrary("p.dll");





:


: 2015-10-01; !; : 370 |


:

:

, - , ; , - .
==> ...

1429 - | 1451 -


© 2015-2024 lektsii.org - -

: 0.014 .