안녕하십니까.
델파이를 시작한지 얼마안된 초보입니다.
비주얼씨로 Dll을 만들어서 델파이에서 사용하려고 합니다.
해더파일없이 CPP로만 함수를 만들어서 Dll을 만들었습니다.
========================================소스==============================================
// TestDll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include <afxdllx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE TestDllDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("NODEDLL.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(NodeDllDLL, hInstance))
return 0;
// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
new CDynLinkLibrary(NodeDllDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("TESTDLL.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(TestDllDLL);
}
return 1; // ok
}
extern "C" __declspec(dllexport) void __cdecl Test()
{
}
위 소스와 같이 함수안에는 아무내용도 없습니다.
이 함수를 델파이에서 정의하는 부분과 호출하는 부분입니다.
=======================================소스===============================================
implementation
const NODEDLL = 'TestDll.dll';
procedure Test(); cdecl; external NODEDLL;
procedure TmainForm.FormCreate(Sender: TObject);
begin
Test;
end;
위와같이 코딩을 하였습니다.
컴파일과 실행은 잘 돼었습니다.
하지만, Visual C++에서 DLL을 수정하여 DLL파일이 있는 폴더에 OverWrite 하면,
DLL파일이 열려있어 복사할 수 없다는 메시지가 나옵니다.
왜이런 일이 생긴는지 저로써는 알수 있는 방법이 없습니다.
그럼 많은 조언부탁드립니다. 수고하십시오.
|