Solved

Passing HBitmap from Delphi to C DLL.

Posted on 2004-03-23
1
493 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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