Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create System.Array

24 views
Skip to first unread message

Martin Zugec

unread,
Sep 19, 2008, 4:46:08 AM9/19/08
to
Hi guys,

probably very stupid question, but I got stuck on this one :(

I am working with MFCOM (COM interface for Citrix) and one of
properties requires Array as input type...

So I tried simple code, [Array]$Schedules = @(), however to my
surprise System.Array is only base object (never realized that
before).

# [array]$Schedules = @()
# $Schedules.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[]
System.Array

If I try to assign this value to COM, it will return error message
stating that input type is not supported.

I cannot use [System.Array]$Schedules or New-Object (no
constructor)...

Any idea???

Thanks,
Martin

Gerd Schneider

unread,
Sep 19, 2008, 7:32:01 AM9/19/08
to
No, definitely not a stupid question.

I'm writing COM objects of my own in C++, mainly for use with VBS but I
occasionally also reference them from PS. This is the interface of a method"
Attrib" which sets attributes on files. The attribut-changes must be provided
as an array of BSTRs '+r', '-r', '+h', '-h' ...

void Attrib (
BSTR bstrPath // Single target file path
SAFEARRAY** ppavArgs // Array of attribute strings
)

$mycomref.Attrib( 'c:\temp\test.txt', [ref]@( '+r', '+h', '+s' ) )

... sets the file to "RHS" from PS. I'm not sure if this exactly matches
your scenario, but basically PS arrays may directly be used as COM array
parameters this way.

--
Gerd

0 new messages