[delphi] 델파이 DLL을 VC++에서 사용하기
* 델파이
uses
SysUtils, Classes;
{$R *.res}
//==================================================================
function dfSum(a,b:Integer):Integer; StdCall; export;
begin
result := a+b ;
end;
exports
dfSum;
//==================================================================
begin
end.
* VC++
//1
typedef int(WINAPI * dfSum) (int a, int b);
dfSum dll_func = NULL;
//2
//typedef void (LPPROC*)(int a, int b);
void CDel2VCDlg::OnOK()
{
// TODO: Add extra validation here
HINSTANCE hInst = NULL;
hInst = LoadLibrary( "del_calc.dll" );
if ( hInst != NULL ) {
//1
dll_func = (dfSum)GetProcAddress(hInst, "dfSum");
if (dll_func != NULL) {
int re = dll_func(1, 2);
//int re = (*dll_func)(1, 2); //이것도 됨
}
FreeLibrary(hInst);
}
CDialog::OnOK();
}
* 델파이
uses
SysUtils, Classes;
{$R *.res}
//==================================================================
function dfSum(a,b:Integer):Integer; StdCall; export;
begin
result := a+b ;
end;
exports
dfSum;
//==================================================================
begin
end.
* VC++
//1
typedef int(WINAPI * dfSum) (int a, int b);
dfSum dll_func = NULL;
//2
//typedef void (LPPROC*)(int a, int b);
void CDel2VCDlg::OnOK()
{
// TODO: Add extra validation here
HINSTANCE hInst = NULL;
hInst = LoadLibrary( "del_calc.dll" );
if ( hInst != NULL ) {
//1
dll_func = (dfSum)GetProcAddress(hInst, "dfSum");
if (dll_func != NULL) {
int re = dll_func(1, 2);
//int re = (*dll_func)(1, 2); //이것도 됨
}
FreeLibrary(hInst);
}
CDialog::OnOK();
}
반응형
'Code' 카테고리의 다른 글
제로보드 XE 1.0.3 설치 (0) | 2008.11.05 |
---|---|
Visual Studio 2008(vc9) 설정을 Visual Studio 6(vs6)으로 바꾸기 (0) | 2008.11.05 |
[cpp] 가상함수 (0) | 2008.11.05 |
Installing VS6 without the Java VM (0) | 2008.11.05 |
[delphi] 델파이창 여러개 띄우기 (0) | 2008.11.05 |