I try WinRT in Delphi. The following code encounter access violation when invoke get_Thumbprint
:
program Sample;
uses
System.SysUtils,
System.Classes,
System.Win.WinRT,
System.NetEncoding,
Winapi.Windows,
Winapi.ActiveX,
Winapi.WinRT.Utils,
Winapi.Winrt,
Winapi.CommonTypes,
Winapi.Security.Cryptography;
begin
CoInitialize(nil);
var q := TCertificates_CertificateQuery.Create;
var B := TBytes.Create(1, 2, 3, 4);
q.put_Thumbprint(Length(B), @B[0]);
var D: TBytes;
SetLength(D, 1000);
var h := q.get_Thumbprint(1000, @D[0]);
end.
The get_Thumbprint
declared as
Certificates_ICertificateQuery = interface(IInspectable)
...
function get_Thumbprint(resultSize: Cardinal; resultValue: PByte): HRESULT; stdcall;
procedure put_Thumbprint(valueSize: Cardinal; value: PByte); safecall;
end;
There are a number of GET methods in Delphi's WinRT declare similarly and it cause access violation invoke the methods. Perhaps I miss some crucial steps to invoke the methods?