Solved

Passing HBitmap from Delphi to C DLL.

Posted on 2004-03-23
1
494 Views
Last Modified: 2010-04-05
Hi,
   I am trying to pass a HBITMAP from Delphi to a C DLL and am getting access violation.

Here's my delphi wrapper. "myPic" is a TBitmap object.
result      := TEST_DLL( HBITMAP(myPic.Handle) );

and here is the C function declaration:

IMGPRO_API IMGP_RESULT Test(HBITMAP i_HBmp);

Any idea why this is so.

Thanks a lot.
0
Comment
Question by:limin123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
Russell Libby earned 100 total points
ID: 10664314
Only 3 things come to mind...

1.) myPic object is nil (not assigned)
2.) There is a problem in the dll function itself
3.) Calling convention is not correct (one is cdecl, the other stdcall, etc). Check the calling convention for the C dll and make sure your Delphi declaration matches

eg:

function FunctionName(params....): ResultType; stdcall; external 'dllname.dll';
or
function FunctionName(params....): ResultType; cdecl; external 'dllname.dll';
etc...

-----

Regards,
Russell

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question