|
너무 초보적인 질문이라도 답변 부탁드립니다.
메인폼 하나와
Unit 하나를 생성하고
아래와 같이 클래스를 선언했습니다.
유닛에 코딩한 함수입니다.
#include "TempClass.h"
//HINSTANCE m_hHandle;
bool TTempClass ::AFunc(void)
{
//Library Load
m_hHandle = LoadLibrary(("C\\aaa.dll").c_str());
if (m_hHandle == NULL) return false;
//Get Proc Address Set
Initialize = (DWORD(__stdcall*)(void*))GetProcAddress(m_hHandle , "C_Initialize");
}
bool TTempClass ::BFunc(void)
{
}
Unit 헤더파일에 아래와 같이 선언했습니다.
#ifndef TempClassH
#define TempClassH
//Class Define
class TTempClass
{
private:
HINSTANCE m_hHandle;
DWORD (WINAPI* Initialize)(void* m_pReserved);
public:
bool AFunc(void);
bool BFunc(void);
}
메인폼에 아래와 같이 선언했습니다.
//HSM Library & Connect class
TTempClass* tempclass;
//---------------------------------------------------------------------------
//Form Show Event
//---------------------------------------------------------------------------
void __fastcall Tfmainform::FormShow(TObject *Sender)
{
if (tempclass->AFunc())
{
}
if (tempclass->BFunc())
{
}
}
이렇게 컴파일해서 실행하니
LoadLibrary 함수 처리할때 Exception 에러가 납니다.
또한
GetProcAddress
부분에서도 Exception 에러가 나네요.
HINSTANCE m_hHandle;
선언을 유닛에 선언하면 에러가 나질 않네요.
|