快速业务通道

BCB编写DLL终极手册

作者 佚名技术 来源 程序设计 浏览 发布时间 2012-06-30
ll[256] = "BCB Load VC_Win32 Dll by __stdcall mode is OK!";
return strRetStdcall;
}
extern "C" __declspec(dllexport) LPSTR __cdecl BCBLoadVCWin32Cdecl()
{
static char strRetCdecl[256] = "BCB Load VC_Win32 Dll by __cdecl mode is OK!";
return strRetCdecl;
}
extern "C" __declspec(dllexport) LPSTR __fastcall BCBLoadVCWin32Fastcall()
{
static char strRetFastcall[256] = "BCB Load VC_Win32 Dll by __fastcall mode is OK!";
return strRetFastcall;
}

??êμ?ˉì?μ÷ó?ó?μ÷ó? BCB ±àD′μ? DLL ??óD??±e£?1??üê?2é?′ DLL μ?μ?3?oˉêy??×??éò?ê1ó? tdump.exe(BCB1¤??) ?ò?? dumpbin.exe(VC1¤??) 2é?′

tdump -ee MyDll.dll >1.txt (2é?′ 1.txt ???t?′?é)
óéóú VC6 2??§3? __pascall ·?ê?£???????3?ò???èy??·?ê?μ?ày×ó
void __fastcall TForm1::btnBLVCWin32DynClick(TObject *Sender)
{
/*cmd: tdbump VCWin32.dll >1.txt
Turbo Dump??Version 5.0.16.4 Copyright (c) 1988, 1998 Borland International
Display of File VCWIN32.DLL
EXPORT ord:0000=''BCBLoadVCWin32Fastcall::''
EXPORT ord:0001=''BCBLoadVCWin32Cdecl''
EXPORT ord:0002=''_BCBLoadVCWin32Stdcall@0''
*/
if ( !DllInst )
DllInst = LoadLibrary ( "VCWin32.dll" );
if ( DllInst )
{
BCBLoadVCWin32Stdcall = (LPSTR (__stdcall *) () )
GetProcAddress ( DllInst, "_BCBLoadVCWin32Stdcall@0" ); //VC Dll
// GetProcAddress ( DllInst, "BCBLoadVCWin32Stdcall" ); //BCB Dll
if ( BCBLoadVCWin32Stdcall )
{
ShowMessage( BCBLoadVCWin32Stdcall() );
}
else ShowMessage ( "Can''t find the __stdcall Function!" );
BCBLoadVCWin32Cdecl = (LPSTR (__cdecl *) () )
GetProcAddress ( DllInst, "BCBLoadVCWin32Cdecl" );
if ( BCBLoadVCWin32Cdecl )
{
ShowMessage( BCBLoadVCWin32Cdecl() );
}
else ShowMessage ( "Can''t find the __cdecl Function!" );
//Why?2?ê? ''BCBLoadVCWin32Fastcall::'',??ê? ''@BCBLoadVCWin32Fastcall@0''£?
BCBLoadVCWin32Fastcall = (LPSTR (__fastcall *) () )
//GetProcAddress ( DllInst, "BCBLoadVCWin32Fastcall::" );
GetProcAddress ( DllInst, "@BCBLoadVCWin32Fastcall@0" );
if ( BCBLoadVCWin32Fastcall )
{
ShowMessage( BCBLoadVCWin32Fastcall() );
}
else ShowMessage ( "Can''t find the __fastcall Function!" );
}
else ShowMessage ( "Can''t find the Dll!" );
}

6. ?2ì?μ÷ó?ày×ó

?2ì?μ÷ó?óDμ??é·3£?′ó?ˉì?μ÷ó??D?éò??aμàμ?3?oˉêyμ???×?£?μ?ê??±?óê±(?óè? lib ???tμ?1¤3ì???t)

Linker ìáê?2??ü?òμ?oˉêyμ?êμ??

′ó 4 ?′3?£??éò??óè? def ???tá??ó

(?éò?í¨1y impdef MyDll.def MyDll.dll ??μ?μ?3?±í)

?¨á¢ó? DLL ???t??ò??ùμ? def ???tó? lib ???tò??e?óè?μ?1¤3ì???t

é???μ? DLL(VCWIN32.dll) μ? def ???t?a(VCWIN32.def)£o

LIBRARY???? VCWIN32.DLL
IMPORTS
@BCBLoadVCWin32Fastcall???? = VCWIN32.@BCBLoadVCWin32Fastcall@0
_BCBLoadVCWin32Cdecl????????= VCWIN32.BCBLoadVCWin32Cdecl
BCBLoadVCWin32Stdcall?????? = VCWIN32._BCBLoadVCWin32Stdcall@0

??ó|μ?oˉêyéù?÷oíêμ??è???£o

extern "C" __declspec(dllimport) LPSTR

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号