Re: problem using delphi dll in vc++
- From: Ryanivanka <sarah.hhyy@xxxxxxxxx>
- Date: Mon, 21 Apr 2008 01:54:31 -0700 (PDT)
thank you all.....I found out there are something wrong about the
function.
So I just want to realize it by myself.Thank you all.
On 4月19日, 上午5时20分, Tamas Demjen <tdem...@xxxxxxxxxx> wrote:
Ryanivanka wrote:
------------------------in c++ .h-------------------------
extern "C" {
__declspec(dllimport) HMODULE __stdcall func1();
}
------------------------------------------------------------
-----------------------in delphi-----------------------------
function func1: dword; stdcall;
----------------------------------------------------------------
They look compatible.
I just don't understand how you were able to link a Delphi DLL
statically. Borland/CodeGear uses OMF-type LIB files, VC++ uses the COFF
format. They're not compatible. Not even for simple import libraries.
So you either have a bug in the Delphi function, or in the import
library. I recommend that you forget about that LIB, and just load the
DLL dynamically:
HINSTANCE dll = LoadLibrary("c:\\path\\to\\my.dll");
typedef HMODULE (__stdcall * PtrFunc1)();
PtrFunc1 func1 =
reinterpret_cast<PtrFunc1>(GetProcAddress(dll, "func1"));
...
// use func1 as if it was a regular C function
...
FreeLibrary(dll);
Of course you have to use GetProcAddress for all the other functions
that the DLL might export as well. It may be a little bit of an extra
work (lots of typing), but you can be 100% sure that the functions are
imported correctly.
I just don't know where your LIB file is coming from, it can't be coming
from Delphi. LIB and OBJ files are generally not portable enough.
Tom
.
- References:
- problem using delphi dll in vc++
- From: Ryanivanka
- Re: problem using delphi dll in vc++
- From: Cholo Lennon
- Re: problem using delphi dll in vc++
- From: Ryanivanka
- Re: problem using delphi dll in vc++
- From: Tamas Demjen
- Re: problem using delphi dll in vc++
- From: Ryanivanka
- Re: problem using delphi dll in vc++
- From: Tamas Demjen
- problem using delphi dll in vc++
- Prev by Date: error C2061: syntax error : identifier 'ref'
- Next by Date: Re: Using an icon resource as a button image
- Previous by thread: Re: problem using delphi dll in vc++
- Next by thread: How do you interactively write to a CEditView Window
- Index(es):
Relevant Pages
|