Solved

C-DLL function and huge pointer

Posted on 1997-04-12
10
244 Views
Last Modified: 2010-04-06
After several tries I couldn't implement the following function found
in a C-DLL:

C- Code
// read a complete frame into buffer
      void _export VCVideoFrameRead(void huge *pBuf);

There seems to be problem when I translate it to the following Delphi
Pascal code:

Delphi- Code
// read a complete frame into buffer
      procedure VCVideoFrameRead(pBuf: Pointer); external 'VICAM32';

The data that is transferred from the Video Camera isn't placed in the
buffer that pBuf points to. Is there any solution or better way to
translate the 'huge *pBuf' c- code?

fyi:
Video camera: compro internet camera
dll: Vicam32.DLL
Buffer: 640 X 480 X 24 bytes = 921600 bytes
OS: WIN95
0
Comment
Question by:sirk033097
  • 6
  • 4
10 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 200 total points
ID: 1335340
Try using the CDECL declaration:

   procedure Foo(x: Pointer); cdecl; external 'blah.dll';

If that doesn't work, then post the code you are using in
calling the DLL...where you actually pass the pointer and
how you set the pointer.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335341
Did any of this help??  Can I be of further assistance??
0
 

Author Comment

by:sirk033097
ID: 1335342
Did you receive my additional info
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335343
No...I don't see it here as a comment...did you get my e-mail
address from another question and mail me??  I hope not,
because I get a lot of mail and don't read all of it.
0
 

Author Comment

by:sirk033097
ID: 1335344
Procedure was already declared as cdecl
------------Converted C-Header
{/// read a complete frame into buffer }

procedure VCVideoFrameRead(pBuf: Pointer); cdecl; far;

------------Program call
type
  aryVideoBuffer = array[1..921600] of Byte;



procedure TfrmMain.TimerTimer(Sender: TObject);
var
      MemoryStream: TMemoryStream;
       VideoBuffer: aryVideoBuffer;
                pBuffer: Pointer;
begin
      MemoryStream := TMemoryStream.Create;
      pBuffer := @VideoBuffer;
      VCVideoFrameRead(pBuffer);
      for iCounter := 0 to High(VideoBuffer)-1 do begin
            MemoryStream.Write(VideoBuffer[iCounter],       MemoryStream.SaveToFile('c:\temp\test.bmp');
      MemoryStream.Free;
end;

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:mheacock
ID: 1335345
Have you tried:

   pBuffer := @VideoBuffer[0];
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335346
You might also try:

   VCVideoFrameRead(VideoBuffer);

You might have to cast VideoBuffer to a pointer...

   VCVideoFrameRead(Pointer(VideoBuffer));

You've probably guessed correctly that I debug by trial and
error...its after I've gotten something working in this manner
that I then try and figure out why it worked.  Please tell me
the results of these.

I don't really see why it won't work the way you've got it now...is this a third-party DLL??  You are using Delphi 1.0,
I'm guessing and that the DLL is 16-bit.  What else...ummm...
if it is your own DLL, have you tried explicity declaring it
CDECL or maybe Pascal??
0
 

Author Comment

by:sirk033097
ID: 1335347
Small problem: I only see the answer you proposed the first time. Is there anyway I can have an overview of the answers-responses.
0
 

Author Comment

by:sirk033097
ID: 1335348
After adding a comment I get an overview of the question history  it would sure be handier it the program would do it the first time I visit the page instead of adding comments to see what has been going on.

I'll try your proposals.

Fyi. 32 bit third party C-DLL with only header file supplied. No source. All the other (non pointer) functions/procedures work fine but when I use function/procedures that use pointers nothing works (only the Exception handler). I'm using a Delphi 2.0 program to access the DLL. But since the other functions work properly I think the problem can be isolated to the pointer 'stuff'.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335349
If it is a 3rd party DLL, use the STDCALL convention, unless
they explicitly tell you to use CDECL.  The majority of 32-bit
DLLs use the STDCALL convention...Microsoft recommends it.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now