AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

OleVariant PSafeArray

Ein Thema von Berni68 · begonnen am 5. Jan 2022 · letzter Beitrag vom 10. Jan 2022
 
Berni68

Registriert seit: 9. Jan 2006
Ort: Villingen
162 Beiträge
 
Delphi XE5 Professional
 
#5

AW: OleVariant PSafeArray

  Alt 7. Jan 2022, 10:57
Hallo,

ich habe nun fogendes herausbekommen:
der OLE-server erwartet ein Array mit 12 Byte.
Die Schnittstelle lässt nur OleVariant zu: (var ReferenceKey: {NOT_OLEAUTO(PSafeArray)}OleVariant; KeyContext: Integer)
der KeyContext ist in diesem Kontext egal.

Ich will jetz ein OleVariant bauen das das 12 Byte array enthält:
Delphi-Quellcode:
function test:OleVariant;
var i: integer;
  Pb: Pointer;
  Vb: OleVariant;
  b: TBytes;
    tsa: TSafeArray;
    psa: PSafeArray;
    tag: TSafeArrayBound;
  P: Pointer;
  V: OleVariant;
begin
  SetLength(b,12); for i:=0 to 11 do b[i]:=0;
  Vb:= VarArrayCreate([0, 12], varByte);
  Pb:= VarArrayLock(Vb);
  Move(b[0], Pb^, 12);
  VarArrayUnlock(Vb);

  tsa.cDims:= 1;
  tsa.fFeatures:= 0001; // <-??   
  tsa.cbElements:= 12;
  tsa.cLocks:= 0001; // <-??
  tsa.pvData:= Pb; ;
    tag.lLbound:= 0;
    tag.cElements:= 12;
    tsa.rgsabound[0]:=tag;
  psa:= @tsa;

  V:= VarArrayCreate([0,0], varDispatch); // nicht: varVariant,varDispatch
  P:= VarArrayLock(V);
  Move(psa, P^, SizeOf(psa));
  VarArrayUnlock(V);

  Result:= V;
end;
wenn ich das nun Aufrufe:

MS.Item[1].GetReferenceKey(test, 0); erhalte ich als Fehlermeldung nicht mehr "Typenkonflikt" sondern
"Variante oder sicheres Array ist gesperrt"
(Zumindest wird die OleVariant mal akzeptiert)

Weiß jemand Rat?
tsa.fFeatures
tsa.cLocks
Bernhard

Geändert von Berni68 ( 7. Jan 2022 um 11:01 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz