Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C-DLL function and huge pointer

Posted on 1997-04-12
10
Medium Priority
?
255 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 600 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
Industry Leaders: 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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