Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to declare Pointer variables in Type Library?

24 views
Skip to first unread message

Ma Xiaoguang

unread,
May 13, 2008, 10:24:55 PM5/13/08
to
Dear ladies and gentlemen,

I need to declare Pointer variables in Type Library for an ActiveX
component. But I don't know which data type is corresponding to Pointer in
Type Library. Please give me some suggestions. Thank you very much.

Best regards.

Xiaoming


Remy Lebeau (TeamB)

unread,
May 14, 2008, 12:55:49 PM5/14/08
to

"Ma Xiaoguang" <maxiaogu...@hotmail.com> wrote in message
news:482a...@newsgroups.borland.com...

> I need to declare Pointer variables in Type Library for
> an ActiveX component.

Why? Untyped pointers are safe in ActiveX. What are you trying to
accomplish exactly?

> But I don't know which data type is corresponding to
> Pointer in Type Library.

void*


Gambit


Ma Xiaoguang

unread,
May 14, 2008, 8:44:23 PM5/14/08
to
Hi Remy,

> Why? Untyped pointers are safe in ActiveX. What are you trying to
> accomplish exactly?

One of my friend asked me to encapsulate component MCDBurner in ActiveX.
In this component, it has the following method:

function InsertMemoryFile(DestinationPath, LongFileName, ShortFileName:
String; Attr: Byte; Memory: Pointer; Size: Cardinal): Integer;

So, I need to declare this method in Type Library, and with which to call
the original method.

That's why I need to declare Pointer variable (actually Pointer
parameter) in Type Library.

May thanks for your help.

Best regards.

Xiaoming


Ma Xiaoguang

unread,
May 15, 2008, 1:53:22 AM5/15/08
to
Hi Remy,

> void*

I can not specify void* as the data type in Type Library. Give me some
suggestions, please. Thank you very much.

Best regards.

Xiaoming


Remy Lebeau (TeamB)

unread,
May 15, 2008, 1:03:12 PM5/15/08
to

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:482b19b5$1...@newsgroups.borland.com...

> Untyped pointers are safe in ActiveX.

I meant *unsafe*.


Gambit


Remy Lebeau (TeamB)

unread,
May 15, 2008, 1:15:30 PM5/15/08
to

"Ma Xiaoguang" <maxiaogu...@hotmail.com> wrote in message
news:482b8765$1...@newsgroups.borland.com...

> One of my friend asked me to encapsulate component
> MCDBurner in ActiveX. In this component, it has the following
> method:
>
> function InsertMemoryFile(DestinationPath, LongFileName, ShortFileName:
> String; Attr: Byte; Memory: Pointer; Size: Cardinal): Integer;
>
> So, I need to declare this method in Type Library, and with
> which to call the original method.

I suggest you implement your ActiveX object to accept an IStream as input
instead of trying to use a raw memory pointer (which you can't do in ActiveX
anyway). The VCL has a TStreamAdapter class available that exposes IStream
access to a TStream. Your friend can load his data into any TStream he
wants, such as a TMemoryStream or TFileStream, then use TStreamAdapter to
pass an IStream to your ActiveX, which can extract the raw bytes and pass
them to MCDBurner as needed, ie (untested):

public
function InsertData(DestinationPath, LongFileName, ShortFileName:
WideString; Attr: Byte; Data: IStream): Integer; safecall;

function TMyActiveXObject.InsertData(DestinationPath, LongFileName,
ShortFileName: WideString; Attr: Byte; Data: IStream): Integer; safecall;
var
statstg: TStatStg;
Buf: PByte;
NumRead: ULONG
begin
Data.Stat(statstg, STATFLAG_NONAME);
GetMem(Buf, statstg.cbSize.LowPart);
try
Data.Read(Buf, statstg.cbSize.LowPart, NumRead);
Result := Burner.InsertMemoryFile(DestinationPath, LongFileName,
ShortFileName, Attr, Buf, NumRead);
finally
FreeMem(Buf);
end;
end;


Gambit


Ma Xiaoguang

unread,
May 15, 2008, 9:07:13 PM5/15/08
to
Hi Remy,

Many thanks for your detailed and patient explanations.

Best regards.

Xiaoming


0 new messages