Solved

C-DLL function and huge pointer

Posted on 1997-04-12
10
249 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
Independent Software Vendors: 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!

 
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

Independent Software Vendors: 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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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