Re: Byte Array aus C++ DLL in VB importieren



Hallo!

Alexander Mueller schrieb:
Btw, weißt Du, ob ein als (byte * pArrData) btw (byte ** ppArrData)
deklarierter Parameter in COM legal ist, insbesondere wenn die Methode
automations-kompatibel sein soll (IDispatch) und ob er in VB unterstützt
würde?

Legal ist das natürlich, aber *nicht* automatisierungs-kompatibel. Und dann funktioniert es selbst in CPP nicht, wenn die Aufrufe über Prozess-Grenzen hinweg verlaufen. Da Du keine weiteren Informationen über das Array hast, kann Marshalling nicht stattfinden. So, wie es eben dort steht, ist der nackte Pointer ein Pointer auf ein einziges Element. Nur dieses wird dann übertragen. Willst Du mehr, musst Du noch weitere Parameter in die Liste einarbeiten, die Du in der IDL mit den Attributen length_is, size_is, first_is usw. ausschmückst. Bei SAFEARRAYs hingegen bekommst Du alle diese Informationen frei Haus.

Übrigens, wenn Du nicht nur automatisierungs-kompatibel sein willst, sondern auch scriptable, so darfst Du als Array-Type nur VARIANT benutzen. Oder in IDL gesprochen: SAFEARRAY(VARIANT)*

Wie auch immer, hatte mir geholfen meine CPP/ATL Skills zu schulen.
Für den Trick mit dem (SAFEARRAY (byte) * ppsa) in der IDL
der in der Implementation als (SAFEARRAY ** ppsa) deklariert wird,
musste ich ziemlich googlen (MIDL2139) ;-)

Wobei der "Trick" auch in dem von mir verlinkten Artikel Erwähnung findet (Scenario 3). ;-)

Gruß,
René
.



Relevant Pages

  • Re: How to Pass a SafeArray of UDTs as VARIANT
    ... Check if your UDT is output in the generated type library. ... you need to write a little IDL ... >I want to pass a safearray of UDT's as VARIANT so the safearray can be an ... > optional parameter when passed from VB. ...
    (microsoft.public.vc.atl)
  • Re: Problem with SAFEARRAY as property accessors.
    ... > could you plz tell me how to define these properties in .cpp file ... A SAFEARRAY(Whatever) parameter in IDL becomes SAFEARRAY* in C++. ... C++ you always specify one extra level of indirection compared to IDL ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Problem with SAFEARRAY as property accessors.
    ... > could you plz tell me how to define these properties in .cpp file ... A SAFEARRAY(Whatever) parameter in IDL becomes SAFEARRAY* in C++. ... C++ you always specify one extra level of indirection compared to IDL ...
    (microsoft.public.vc.atl)
  • Re: Marshalling a SAFEARRAY from an ATL component into CS.
    ... You should indicate the type of SAFEARRAY element, so your IDL should look ... >> Please post your method declaration. ... >>> returns a SAFEARRAY of INTs, but my C# component chokes on it. ...
    (microsoft.public.dotnet.languages.csharp)

Loading