Solved

C-DLL function and huge pointer

Posted on 1997-04-12
10
252 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

624 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