• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

putting c++ into delphi

I have this line in a C++ library :
#define INSTANCE_DATA_OF_PROPERTY_PTR(x) ( (PKSPROPERTY((x)) ) + 1 )
where PKSPROPERTY is a pointer type to a Record type, and x is an integer.

I'm interested in making that C++ macro, a Delphi function.
Could someone give me a hand?
The thing is I do not know for sure what's the CAST PKSPROPERTY returning... Probably the instance, or handle, or pointer memory address.

Thanks!
0
5pn
Asked:
5pn
1 Solution
 
robert_marquardtCommented:
x is typecasted to a PKSPROPERTY which seems to be a pointer to a record.
 + 1 to a typed pointer in C (this is C not C++) gives the pointer to the next record.

function INSTANCE_DATA_OF_PROPERTY_PTR(x: PKSPROPERTY): PKSPROPERTY;
begin
  Result := PKSPROPERTY(Cardinal(X) + SizeOf(KSPROPERTY));
end;

Maybe the function is more convienient if Pointer is used instead of PKSPROPERTY. This depends on the intended usage.
0
 
5pnAuthor Commented:
I eventually ended up with a similar thing.
Result:=Ptr (Cardinal(X) + 24) where 24 is the number of bytes occupied by KSPROPERTY.
Not sure 100% of your code, but still... it's a great thing to have another idea.
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now