<<°­ÁÂ>> DLL vb¿¡¼­ »ç¿ëÇϱâ-¾÷±×·¹À̵å(4.9.8.0¹öÀü¿ë) [º¸³Ê½º - DLL µ¨ÆÄÀÌ¿¡¼­ »ç¿ëÇϱâ]
1.¸Þ´º¿¡¼­ ÆÄÀÏ->»õ·Î¸¸µé±â-> ÇÁ·ÎÁ§Æ® ¼±Åà : Dev-C++ 4.9.8.0 ¹öÀü
2.dll ÅÛÇø´ ÇÁ·ÎÁ§Æ®¸¦ ¼±ÅÃ
3. »õ·Î »ý¼ºµÈ ÇÁ·ÎÁ§Æ®¸¦ ÀúÀå
4. ÀÚµ¿À¸·Î »ý¼ºµÈ Çì´õÆÄÀÏ
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */


class DLLIMPORT DllClass
{
  public:
    DllClass();
    virtual ~DllClass(void);

  private:

};

#endif /* _DLL_H_ */

5. ÀÚµ¿À¸·Î »ý¼ºµÈ ¼Ò½º ÆÄÀÏ
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>


DllClass::DllClass()
{

}


DllClass::~DllClass ()
{

}


BOOL APIENTRY
DllMain (
  HINSTANCE hInst     /* Library instance handle. */ ,
  DWORD reason        /* Reason this function is being called. */ ,
  LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;
      case DLL_PROCESS_DETACH:
        break;
      case DLL_THREAD_ATTACH:
        break;
      case DLL_THREAD_DETACH:
        break;
    }
    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}

6. À§ÀÇ ¼Ò½ºµé¿¡ »ç¿ëÀÚ Á¤ÀÇ ÇÔ¼ö¸¦ ³Ö±â
Çì´õÆÄÀÏ
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */




extern "C" __declspec(dllexport) int AddInteger(int a, int b);

class DLLIMPORT DllClass
{
  public:
    DllClass();
    virtual ~DllClass(void);

  private:

};

#endif /* _DLL_H_ */


¼Ò½ºÆÄÀÏ
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>


DllClass::DllClass()
{

}


DllClass::~DllClass ()
{

}


BOOL APIENTRY
DllMain (
  HINSTANCE hInst     /* Library instance handle. */ ,
  DWORD reason        /* Reason this function is being called. */ ,
  LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;
      case DLL_PROCESS_DETACH:
        break;
      case DLL_THREAD_ATTACH:
        break;
      case DLL_THREAD_DETACH:
        break;
    }
    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}

extern "C" __declspec(dllexport) int AddInteger(int a, int b)
{ 
return a+b; 
} 
7. À§ÀÇ ¼Ò½ºµéÀ» DevC++¿¡¼­ ÄÄÆÄÀÏ
8. VB¿¡¼­ Ç¥ÁØ exe·Î »õ ÇÁ·ÎÁ§Æ®¸¦ »ý¼º, Ä¿¸Çµå ¹öư Çϳª Ãß°¡, ¸ðµâ Ãß°¡
9. »ý¼ºµÈ mydll.dll ÆÄÀÏÀ» vb ¼Ò½ºÆÄÀÏÀÌ ÀÖ´Â °÷¿¡ º¹»ç
10. ¸ðµâ¿¡ dllÀ» »ç¿ëÇÒ ¼ö ÀÖ°Ô ÄÚµù
11. Æû¿¡ ÄÚµù
12. ¸Þ´º¿¡¼­ ~.exe ¸¸µé±â ¼±Åà (ÁÖÀÇ! IDE »ó¿¡¼­ RunÀ» ½ÇÇàÇÏ¸é ¿¡·¯ ¹ß»ýÇÔ.)
13. ÀúÀåÇÒ exe ÆÄÀϸí ÀÛ¼ºÇϰí ÀúÀåÇϸé ÄÄÆÄÀϵÊ
14. ÄÄÆÄÀÏ µÈ project1.exe ÆÄÀÏÀ» ½ÇÇàÇϸé Á¦´ë·Î dllÀ» È£ÃâÇÏ´Â °á°ú°¡ ³ª¿È.
15. º¸³Ê½º - Delphi ¿¡¼­µµ dll À» È£ÃâÇϱâ.
1) µ¨ÆÄÀÌ ¸Þ´º¿¡¼­ File -> New -> Application À» ¼±ÅÃ

2) Æû¿¡ ¹öưÀ» Ãß°¡Çϰí, ¿¡µðÆ®µµ Ãß°¡ÇÑ´Ù.

3) unit.pas ¿¡¼­ ¾Æ·¡ÀÇ »¡°£ »ç°¢Çü¾ÈÀÇ ³»¿ëÀ» Ãß°¡ÇÑ´Ù.
(µÎ¹øÂ° »¡°£»ç°¢Çü¾ÈÀÇ ³»¿ëÀº ÆûÀÇ ¹öưÀ» ´õºíŬ¸¯ÇÑÈÄ Ãß°¡ÇÑ´Ù.)
ù¹øÂ° »¡°£»ç°¢Çü¾ÈÀÇ ³»¿ë (mydll.dll ÆÄÀÏÀ» µ¨ÆÄÀÌ ¼Ò½º°¡ Àִ°÷¿¡ º¹»ç)
function AddInteger(a, b: integer):integer; far; cdecl; external 'mydll.dll'

µÎ¹øÂ° »¡°£»ç°¢Çü¾ÈÀÇ ³»¿ë
edit1.text:=inttostr(AddInteger(10,5));

4) ½ÇÇàÇØ¼­ °á°ú´Â ¹öưÀ» ´­·¯º¸¸é 15°¡ ³ª¿Â´Ù.