Moinsen,
ich bräuchte Hilfe den folgenden .NET Code in Delphi Code zu übersetzen.
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| l_Filename = Application.CommonAppDataPath + "\\ERP-Account " + l_SendParameter.AccountID + ".cer"; byte[] l_Certificate; using (FileStream i_FileStream = System.IO.File.Open(l_Filename, FileMode.Open)) { BinaryReader l_Reader = new BinaryReader(i_FileStream); l_Certificate = l_Reader.ReadBytes((int)i_FileStream.Length); }
l_InvoiceClient.Init(i_InvoiceURL, i_InvoiceURL2, l_SendParameter.AccountID, l_Certificate, Guid.NewGuid(), "Client", "1.0", "XiErpTestClient"); |
Das Problem ist das ich als Rückgabetyp ein PSafeArray benötige.
Meine Funktion sieht zur Zeit so aus:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7:
| function HoleZertifikat(AcountID: String): PSafeArray; var Datei: TFileStream; begin Datei := TFileStream.Create(ExtractFilePath(ParamStr(0)+'\Zertifikate\'+AcountID+'.cer'), fmOpenRead);
end; |
Der Importassistent für die Typbibliothek hat die Init-Methode folgendermaßen in Delphi übersetzt.
Delphi-Quelltext
1: 2: 3:
| procedure Init(const URL: WideString; const URL2: WideString; const AccountID: WideString; Certificate: PSafeArray; ClientGuid: TGUID; const ClientName: WideString; const ProductVersion: WideString; const ProgramID: WideString); safecall; |
Ich weiß aber nicht wie ich den Inhalt der Datei in ein PSafeArray bekommen soll.
Kennt jemand von euch eine Lösung?
MFG
Lars