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

Header Translation: Windows PropSys API

89 views
Skip to first unread message

Andrew Fiddian-Green

unread,
Mar 30, 2008, 1:11:15 PM3/30/08
to
Hi,

I was unable to find any header translations for the Interfaces declared
in the Windows PropSys API so I made an attempt at translating (some of)
the source code from PropSys.idl from the Windows SDK into Pascal (below).

This is more or less the first time I did such a thing, so would
appreciate if somebody would be willing to cross check it for me.

Regards,
AndrewFG

++++

From PropSys.idl
================

[
uuid(b7d14566-0509-4cce-a71f-0a554233bd9b),
object,
pointer_default(unique)
]
interface IInitializeWithFile : IUnknown
{
HRESULT Initialize(
[in, string] LPCWSTR pszFilePath,
[in] DWORD grfMode);
}

[
uuid(b824b49d-22ac-4161-ac8a-9916e8fa3f7f),
object,
pointer_default(unique)
]
interface IInitializeWithStream : IUnknown
{
[local] HRESULT Initialize(
[in] IStream *pstream,
[in] DWORD grfMode);

[call_as(Initialize)] HRESULT RemoteInitialize(
[in] IStream *pstream,
[in] DWORD grfMode);
}

[
uuid(886d8eeb-8cf2-4446-8d02-cdba1dbdcf99),
helpstring("Simple Property Store Interface"),
object,
pointer_default(unique)
]
interface IPropertyStore : IUnknown
{
HRESULT GetCount(
[out] DWORD *cProps);

HRESULT GetAt(
[in] DWORD iProp,
[out] PROPERTYKEY *pkey);

HRESULT GetValue(
[in] REFPROPERTYKEY key,
[out] PROPVARIANT *pv);

HRESULT SetValue(
[in] REFPROPERTYKEY key,
[in] REFPROPVARIANT propvar);

HRESULT Commit();
}

[
uuid(c8e2d566-186e-4d49-bf41-6909ead56acc),
object,
pointer_default(unique)
]
interface IPropertyStoreCapabilities : IUnknown
{
HRESULT IsPropertyWritable([in] REFPROPERTYKEY key);
}
</PropSys.idl>


Delphi Translation
==================

IInitializeWithFile = interface(IUnknown)
['{b7d14566-0509-4cce-a71f-0a554233bd9b}']
function Initialize(pszFilePath: PAnsiChar; grfMode: DWORD):
HRESULT; stdcall;
end;

IInitializeWithStream = interface(IUnknown)
['{b824b49d-22ac-4161-ac8a-9916e8fa3f7f}']
function Initialize(var pIStream: IStream; grfMode: DWORD):
HRESULT; stdcall;
end;

IPropertyStore = interface(IUnknown)
['{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}']
function GetCount(out cProps: DWORD): HRESULT; stdcall;
function GetAt(iProp: DWORD; out PropKey: TPropertyKey): HRESULT;
stdcall;
function GetValue(pPropKey: PPropertyKey; out PropVar:
TPropVariant): HRESULT; stdcall;
function SetValue(pPropKey: PPropertyKey; pPropVar: PPropVariant):
HRESULT; stdcall;
function Commit: HRESULT; stdcall;
end;

IPropertyStoreCapabilities = interface(IUnknown)
['{c8e2d566-186e-4d49-bf41-6909ead56acc}']
function IsPropertyWritable(pPropKey: PPropertyKey): HRESULT; stdcall;
end;

Rudy Velthuis [TeamB]

unread,
Mar 30, 2008, 1:23:18 PM3/30/08
to
Andrew Fiddian-Green wrote:

LPCWSTR (note the W) means PWideChar, NO PAnsiChar. If you are not
sure, the best route is to simply leave it at LPCWSTR. Most of such
types are defined in Windows.pas



> IInitializeWithStream = interface(IUnknown)
> ['{b824b49d-22ac-4161-ac8a-9916e8fa3f7f}']
> function Initialize(var pIStream: IStream; grfMode: DWORD):
> HRESULT; stdcall; end;

Looks fine.

>
> IPropertyStore = interface(IUnknown)
> ['{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}']
> function GetCount(out cProps: DWORD): HRESULT; stdcall;
> function GetAt(iProp: DWORD; out PropKey: TPropertyKey): HRESULT;
> stdcall;
> function GetValue(pPropKey: PPropertyKey;
> out PropVar: TPropVariant): HRESULT; stdcall;
> function SetValue(pPropKey: PPropertyKey;
> pPropVar: PPropVariant): HRESULT; stdcall;
> function Commit: HRESULT; stdcall;
> end;

Looks fine. You can replace "pPropKey: PPropertyKey" with "var
pPropkey: TPropertyKey", if you wish, but that is not necessary. The
REF part of the name makes me think it is passed as a reference, so
that would mean the "var" translation is what is meant.

>
> IPropertyStoreCapabilities = interface(IUnknown)
> ['{c8e2d566-186e-4d49-bf41-6909ead56acc}']
> function IsPropertyWritable(pPropKey: PPropertyKey): HRESULT;
> stdcall; end;

Looks fine.

--
Rudy Velthuis [TeamB] http://www.teamb.com

"Only a free and unrestrained press can effectively expose
deception in government."
-- Hugo Black, Supreme Court Justice

Rudy Velthuis [TeamB]

unread,
Mar 30, 2008, 1:25:05 PM3/30/08
to
Andrew Fiddian-Green wrote:

> Hi,
>
> I was unable to find any header translations for the Interfaces
> declared in the Windows PropSys API so I made an attempt at
> translating (some of) the source code from PropSys.idl from the
> Windows SDK into Pascal (below).
>
> This is more or less the first time I did such a thing, so would
> appreciate if somebody would be willing to cross check it for me.

Except for the wrong translation of LPCWSTR, that looks fine. (LP =
long pointer, C = const, W = wide, STR = string).

--
Rudy Velthuis [TeamB] http://www.teamb.com

"Reality is merely an illusion, albeit a very persistent one."
-- Albert Einstein

Andrew Fiddian-Green

unread,
Mar 30, 2008, 1:50:01 PM3/30/08
to
Rudy Velthuis [TeamB] wrote:

> Looks fine.

Thanks for the fantastic assistance :-)

> You can replace "pPropKey: PPropertyKey" with "var
> pPropkey: TPropertyKey", if you wish, but that is not necessary. The
> REF part of the name makes me think it is passed as a reference, so
> that would mean the "var" translation is what is meant.

I would definitely have used var for an object, but TPropertyKey is a
record and not an object and so I was not sure about it...

AndrewFG

Rudy Velthuis [TeamB]

unread,
Mar 30, 2008, 3:02:05 PM3/30/08
to
Andrew Fiddian-Green wrote:

Do not use objects at all. But records should generally be passed as
var.

--
Rudy Velthuis [TeamB] http://www.teamb.com

"640K ought to be enough for anybody."
-- Bill Gates (1955-), in 1981

0 new messages