晕啊。VC调用delphi动态库的问题,来看看啊
我在VC中LoadLibrary,用delphi写的动态库,其它什么都不做。
当我退出的时候报错0xC0000005:access violation.
就在OnInitDialog里面loadlibrary了,其它什么都没做!!!!
问题点数:50、回复次数:6Top
1 楼cpio(备注)回复于 2006-07-04 17:32:59 得分 10
是不是还要FreeLibrary啊
Top
2 楼sirdan(小李飞盆)回复于 2006-07-04 17:45:34 得分 30
同意楼上的,是要freelibrary。
给你个例子你看看:
// File: RUNTIME.C
// A simple program that uses LoadLibrary and
// GetProcAddress to access myPuts from MYPUTS.DLL.
#include <stdio.h>
#include <windows.h>
typedef VOID (*MYPROC)(LPTSTR);
VOID main(VOID)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("myputs");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) ("message via DLL function\n");
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method\n");
}Top
3 楼dic_walter(c-type blood)回复于 2006-07-04 19:47:38 得分 0
不是啊,我在delphi里面uses sharemem;
这样就没问题了,但在VC中用FreeLibrary的时候,VC却死掉了,��呜呜Top
4 楼zytzjx(wecan)回复于 2006-07-04 19:52:03 得分 10
你要把动态库设定为__stdcall,在VC中申明为__stdcallTop
5 楼dic_walter(c-type blood)回复于 2006-07-04 20:06:11 得分 0
是设置的__stdcall。如果不设置,根本调用的时候就会异常的Top
6 楼dic_walter(c-type blood)回复于 2006-07-12 16:39:26 得分 0
自己顶Top




