![]() |
Richtiger Umgang mit VT_CARRAY / TypeLibrary
Hi,
ich versuche beim Einlesen einer TypeLibrary (tlb, exe, dll, ocx) beim Typ VT_CARRAY an die Information über die Dimensionen der einzelnen Arrays zu gelangen. Bei einem eindimensionalen Array ist das ganze auch kein Problem, aber wie komm ich an die restlichen Dimensionsgrößen? Meine TestLibrary sieht so aus:
Code:
Beim Auslesen der Informationen muss man die Informationen aus einer tagTYPEDESC-Struktur holen. Eigentlich dürfte es da nicht allzuviele Möglichkeiten geben, allerdings komm ich trotzdem nicht weiter.
[
uuid(E12D30C4-3ABF-4349-B81D-609F43EAADB7), version(1.0), helpstring("Project1 Library") ] library Project1 { importlib("stdole2.tlb"); [ uuid(F0CB1737-FF7C-4ECC-B868-640589C76E27), version(1.0), dual, oleautomation ] interface Interface1: IDispatch { [ id(0x000000F9) ] HRESULT _stdcall Method1( [in, out] long** rgrgElems[17][14][12][5] ); [ id(0x000000FF) ] HRESULT _stdcall Method2( [in, out] long** rgrgElems[21] ); }; [ uuid(7E2BEAC1-0BCF-4472-ACC8-C9B9DB8858B0), version(1.0) ] coclass CoClass1 { [default] interface Interface1; }; };
Delphi-Quellcode:
Laut dem Platform SDK sollte das rgbounds-Feld genauso viele TSafeArrayBound-Elemente wie die Dimensions-Anzahl angibt haben. (In meinem Bsp. also 4)
PArrayDesc = ^TArrayDesc;
PTypeDesc = ^TTypeDesc; {$EXTERNALSYM tagTYPEDESC} tagTYPEDESC = record case Integer of VT_PTR: (ptdesc: PTypeDesc; vt: TVarType); VT_CARRAY: (padesc: PArrayDesc); VT_USERDEFINED: (hreftype: HRefType); end; TTypeDesc = tagTYPEDESC; {$EXTERNALSYM tagARRAYDESC} tagARRAYDESC = record tdescElem: TTypeDesc; cDims: Word; rgbounds: array[0..0] of TSafeArrayBound; end; TArrayDesc = tagARRAYDESC; {$EXTERNALSYM tagSAFEARRAYBOUND} tagSAFEARRAYBOUND = record cElements: Longint; lLbound: Longint; end; TSafeArrayBound = tagSAFEARRAYBOUND; Ich versuche durch folgenden Code die Dimensionen auszulesen.
Delphi-Quellcode:
Es wird aber nur bei rgbounds[0] die korrekte Dimension (17) ausgegeben.
procedure test(typeDesc: TTypeDesc);
var i: integer; arrayDesc: tagARRAYDESC; bound: SAFEARRAYBOUND; begin if (typeDesc.vt = VT_CARRAY) then begin arrayDesc := typeDesc.padesc^; ShowMessage('Dimensions: ' + IntToStr(arrayDesc.cDims)); for i:=0 to arrayDesc.cDims-1 do begin bound := arrayDesc.rgbounds[arrayDesc.cDims-1-i]; ShowMessage('Bound: ' + IntToStr(bound.cElements) + '|' + IntToStr(bound.lLbound)); end; end; end; Sieht jemand meinen Fehler? Im Voraus schonmal vielen Dank, Dominik |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:23 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