我的作業系統是Win95,使用Visual C++ 5.0 產生了一個Regular DLL
Function 的內容很簡單如下:
extern "C" __declspec(dllexport) void dll_func(void)
{
......
}
我的呼叫端程式是:
typedef void (CALLBACK *LPFNDLLFUNC)(void);
void TestDllDlg::OnOK()
{
HINSTANCE hDLL; // Handle to DLL
LPFNDLLFUNC lpDllFun; // Function pointer
hDLL = LoadLibrary("newdll.dll");
if (hDLL != NULL)
{
typedef map<CString,LPFNDLLFUNC> map_type;
map_type funcmap; // Declare funcmap
lpDllFun = (LPFNDLLFUNC)GetProcAddress(hDLL , m_funName);
if (!lpDllFun)
{
// handle the error
FreeLibrary(hDLL);
return ;
}
funcmap.insert(map_type::value_type(m_funName , lpDllFun));
MSG message ;
for(;;)
{
if (::PeekMessage(&message , NULL , 0 , 0 , PM_REMOVE))
{
::TranslateMessage(&message) ;
MSG message ;
for(;;)
{
if (::PeekMessage(&message , NULL , 0 , 0 , PM_REMOVE))
{
::DispatchMessage(&message) ;;
}
// call the function
m_lOUTPUT ++ ;
(*funcmap[m_funName])() ;
UpdateData(FALSE);
}
}
}
當我連續呼叫約二十五萬次後會當機, "Stack Overflow"
何解?麻煩高手幫忙。
謝謝 !