[問題] BCB 寫視窗 DLL
最近嘗試 用 BCB 寫DLL
一般的傳值沒有問題,但如果是將 DLL 寫成要呼叫一個視窗出來
程式執行時,就會出現 Acess Violation
已將 dll及 lib檔放到主程式目錄下
呼叫方式為靜態呼叫
以下是我的測試程式 請各位大大幫我看一下
====== dll.cpp DLL 主體 ===============
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
// 被呼叫的視窗 Header File
#include "dll1.h"
USERES("BCB09052_DLL.res");
USEFORM("dll1.h",dllForm);
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
//---------------------------------------------------------------------------
void __declspec(dllexport) __stdcall FormShow(){
TdllForm *f = new TdllForm(NULL);
f->ShowModal();
}
===== main.cpp 呼叫 DLL 的程式 ============
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include "dlldef.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
FormShow();
}
//---------------------------------------------------------------------------
--
If you're not have fun in baseball,
you miss the point of everything.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.152.233
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章