Solved

C-DLL function and huge pointer

Posted on 1997-04-12
10
247 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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
 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 200
HTML text in the body of an email (delphi code) 12 118
Convert GUI app into console app for Win32 Env 5 100
Create a path if not exists 7 77
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

772 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