Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle in a DLL

Status
Not open for further replies.

EliGottlieb

Programmer
May 22, 2002
3
US
I built a COM-like infrastructure (I hate Micrsoft), and typedefed DWORD to be called HSERVER (Handle of Server). Then I wrote 2 functions to encode and decode this handle. I did this all in Delphi. Recently I ported it to C++ Builder and compiled it into a DLL. Now when I call one of my functions from Delphi, the incorrect handle is passed, even though I check the value client-side upon calling the function and it's correct then. Here are the function prototypes:

__declspec(dllexport)
HSERVER _stdcall GetHServer(const IPicOmServer* iServer);

IPicOmServer* _fastcall DecodeHServer(const HSERVER
ServerHandle);

__declspec(dllexport)
IPicOmServer* _stdcall PicOmInitialize(const HSERVER
ServerHandle);

PicOmInitialize() is supposed to decode the passed in handle and then assign the result to a global interface pointer. I don't think it's a problem with the calling convention, because when the client is written in C++ the call works. From any other client language an access violation is raised because you can't decode a bad handle. Please tell me what's wrong. When the library was compiled in Delphi it worked fine.
 
I'm just guessing so I may way off-base. It may have something to do with "name mangling." C++ expects names in DLL to be formatted differently that Delphi. That's about the extent of my knowledge on this subject. :-( James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
All the functions are declared extern "C" so it's not a name mangling problem(extern "C" disables name mangling).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top