vc6.0 工程是win32 Dynamic-link library ,
//.ccp文件内容
#include "stdafx.h"
#include "wdll.h"BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
} return TRUE;
}void _stdcall hello()
{
MessageBox(NULL,"helloworld","OK",MB_OK);
}void _stdcall test3(TPoint* in,TPoint* out)
{
out->x = in->x + 1;
out->y = in->y + 1;
out->z = in->z + 1;
}//.h文件
#pragma once
/*
#ifdef WDLL_EXPORTS
#define WDLL_API __declspec(dllexport)
#else
#define WDLL_API __declspec(dllimport)
#endif */struct TPoint
{
int x,y,z;
};extern "C" void __declspec(dllexport) __stdcall hello();
extern "C" void __declspec(dllexport) __stdcall test3(TPoint* in,TPoint* out);//把vc下生成的wdll.dll放在delphi 目录下,delphi 中调用
...
procedure hello; stdcall; external 'wdll.dll';
....
implementation
下面函数中调用hello,错误提示“无法定位程序输入点hello于动态链接库wdll.dll上。"
这个dll我在VC下调用成功了
//.ccp文件内容
#include "stdafx.h"
#include "wdll.h"BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
} return TRUE;
}void _stdcall hello()
{
MessageBox(NULL,"helloworld","OK",MB_OK);
}void _stdcall test3(TPoint* in,TPoint* out)
{
out->x = in->x + 1;
out->y = in->y + 1;
out->z = in->z + 1;
}//.h文件
#pragma once
/*
#ifdef WDLL_EXPORTS
#define WDLL_API __declspec(dllexport)
#else
#define WDLL_API __declspec(dllimport)
#endif */struct TPoint
{
int x,y,z;
};extern "C" void __declspec(dllexport) __stdcall hello();
extern "C" void __declspec(dllexport) __stdcall test3(TPoint* in,TPoint* out);//把vc下生成的wdll.dll放在delphi 目录下,delphi 中调用
...
procedure hello; stdcall; external 'wdll.dll';
....
implementation
下面函数中调用hello,错误提示“无法定位程序输入点hello于动态链接库wdll.dll上。"
这个dll我在VC下调用成功了
确认一下你调用的dll是你所想调用的那个,在path目录下有没有其它名为wdll.dll的文件
Turbo Dump Version 5.0.16.12 Copyright (c) 1988, 2000 Inprise Corporation
Display of File WDLL.DLLOld Executable HeaderDOS File Size 37034h (225332. )
Load Image Size 450h ( 1104. )
Relocation Table entry count 0000h ( 0. )
Relocation Table address 0040h ( 64. )
Size of header record (in paragraphs) 0004h ( 4. )
Minimum Memory Requirement (in paragraphs) 0000h ( 0. )
Maximum Memory Requirement (in paragraphs) FFFFh ( 65535. )
File load checksum 0000h ( 0. )
Overlay Number 0000h ( 0. )Initial Stack Segment (SS:SP) 0000:00B8
Program Entry Point (CS:IP) 0000:0000
Portable Executable (PE) FileHeader base: 000000E0CPU type 80386
Flags 210E [ executable backwards 32bit library ]
DLL flags 0000 [ ]
Linker Version 6.0
Time stamp 4A8251F3 : Wed Aug 12 13:24:03 2009
O/S Version 4.0
User Version 0.0
Subsystem Version 4.0
Subsystem 0002 [ Windows GUI ]
Object count 00000005
Symbols offset 00000000
Symbols count 00000000
Optional header size 00E0
Magic # 10B
Code size 0002B000
Init Data size 0000D000
Uninit Data size 00000000
Entry RVA 00001430
Image base 10000000
Code base 00001000
Data base 00001000
Object/File align 00001000/00001000
Reserved 00000000
Image size 00039000
Header size 00001000
Checksum 00000000
Stack reserve/commit 00100000/00001000
Heap reserve/commit 00100000/00001000
Number interesting RVAs 00000010
Name RVA Size
------------------ -------- --------
Exports 0002E040 00000196
Imports 00036000 0000003C
Resources 00000000 00000000
Exceptions 00000000 00000000
Security 00000000 00000000
Fixups 00037000 000013D8
Debug 0002C000 0000001C
Description 00000000 00000000
Global Ptr 00000000 00000000
TLS 00000000 00000000
Callbacks 00000000 00000000
Bound Imports 00000000 00000000
Import Addr Table 000361F8 000001BC
Delayed Imports 00000000 00000000
COM Runtime 00000000 00000000
reserved 00000000 00000000Object table:
# Name VirtSize RVA PhysSize Phys off Flags
-- -------- -------- -------- -------- -------- --------
01 .text 0002A200 00001000 0002B000 00001000 60000020 [CER]
02 .rdata 000021D6 0002C000 00003000 0002C000 40000040 [IR]
03 .data 000065E0 0002F000 00005000 0002F000 C0000040 [IRW]
04 .idata 00000AA2 00036000 00001000 00034000 C0000040 [IRW]
05 .reloc 00001811 00037000 00002000 00035000 42000040 [DIR]Key to section flags:
C - contains code
D - discardable
E - executable
I - contains initialized data
R - readable
W - writeable******************************************************************************
Section: Import
ImportLookUpTblRVA:000361C8
Time Stamp: 00000000
Forwarder Chain: 00000000 (index of first forwarder reference)Imports from USER32.dll
(hint = 01BE) MessageBoxAImports from KERNEL32.dll
(hint = 0175) GetVersionExA
(hint = 0262) SetEnvironmentVariableA
(hint = 00CA) GetCommandLineA
(hint = 0174) GetVersion
(hint = 0051) DebugBreak
(hint = 0152) GetStdHandle
(hint = 02DF) WriteFile
(hint = 01AD) InterlockedDecrement
(hint = 01F5) OutputDebugStringA
(hint = 013E) GetProcAddress
(hint = 01C2) LoadLibraryA
(hint = 01B0) InterlockedIncrement
(hint = 0124) GetModuleFileNameA
(hint = 007D) ExitProcess
(hint = 029E) TerminateProcess
(hint = 00F7) GetCurrentProcess
(hint = 00FA) GetCurrentThreadId
(hint = 02A5) TlsSetValue
(hint = 02A2) TlsAlloc
(hint = 02A3) TlsFree
(hint = 0271) SetLastError
(hint = 02A4) TlsGetValue
(hint = 011A) GetLastError
(hint = 00F9) GetCurrentThread
(hint = 026D) SetHandleCount
(hint = 0115) GetFileType
(hint = 0150) GetStartupInfoA
(hint = 0055) DeleteCriticalSection
(hint = 01B8) IsBadWritePtr
(hint = 01B5) IsBadReadPtr
(hint = 01A7) HeapValidate
(hint = 00B2) FreeEnvironmentStringsA
(hint = 00B3) FreeEnvironmentStringsW
(hint = 02D2) WideCharToMultiByte
(hint = 0106) GetEnvironmentStrings
(hint = 0108) GetEnvironmentStringsW
(hint = 0126) GetModuleHandleA
(hint = 0109) GetEnvironmentVariableA
(hint = 019D) HeapDestroy
(hint = 019B) HeapCreate
(hint = 019F) HeapFree
(hint = 02BF) VirtualFree
(hint = 0241) SetConsoleCtrlHandler
(hint = 01AA) InitializeCriticalSection
(hint = 0066) EnterCriticalSection
(hint = 01C1) LeaveCriticalSection
(hint = 0085) FatalAppExitA
(hint = 02AD) UnhandledExceptionFilter
(hint = 022F) RtlUnwind
(hint = 0199) HeapAlloc
(hint = 01A2) HeapReAlloc
(hint = 02BB) VirtualAlloc
(hint = 00BF) GetCPInfo
(hint = 00B9) GetACP
(hint = 0131) GetOEMCP
(hint = 01E4) MultiByteToWideChar
(hint = 0153) GetStringTypeA
(hint = 0156) GetStringTypeW
(hint = 01BF) LCMapStringA
(hint = 01C0) LCMapStringW
(hint = 026A) SetFilePointer
(hint = 0296) Sleep
(hint = 027C) SetStdHandle
(hint = 01BE) IsValidLocale
(hint = 01BD) IsValidCodePage
(hint = 011C) GetLocaleInfoA
(hint = 0077) EnumSystemLocalesA
(hint = 0171) GetUserDefaultLCID
(hint = 00AA) FlushFileBuffers
(hint = 001B) CloseHandle
(hint = 0170) GetTimeZoneInformation
(hint = 011D) GetLocaleInfoW
(hint = 0021) CompareStringA
(hint = 0022) CompareStringW******************************************************************************
Section: Exports
Flags: 00000000
Time Stamp: 4A8235A4 : Wed Aug 12 11:23:16 2009
Major Version: 0000
Minor Version: 0000Exports from wdll.dll
4 exported name(s), 4 export addresse(s). Ordinal base is 1.
Sorted by Name:
RVA Ord. Hint Name
-------- ---- ---- ----
0000100A 1 0000 _hello@0
00001014 2 0001 _test1@8
00001019 3 0002 _test3@8
0000100F 4 0003 _test4@4
函数名变了呵,_hello
__stdcall会改导出的符号。
调用成功了,
extern "C" 只能用 cdecl的方式。。
vc中用的_cdecl 可在delphi 中用的procedure hello;stdcall; external 'wdll.dll';
这是因为你这个是无参数的函数,所以跟stdcall是无差别的,要是有参数就不能这样了。。