Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Querying for a COM Interface

Reply
 
Old 05-01-2007   #1 (permalink)
DouglasWoods


 
 

Querying for a COM Interface

I have come from a C++ background where I have used the following to work
with COM

CComPtr<IBuilder> builder;
builder.CoCreateInstance(__uuidof(Builder));
CComQIPtr<IPersist> loader(builder);

I can see how to use new-object -comobject to create the builder object, but
how do I go about getting the IPersist interface?

Is there a example/tutorial on using COM in Powershell?
--
Douglas Woods

My System SpecsSystem Spec
Old 05-05-2007   #2 (permalink)
Don Jones [MVP]


 
 

Re: Querying for a COM Interface

The Framework's COM interop layer makes a lot of C++-flavored stuff
difficult, and PowerShell's additional adaptation tweaks things a bit
further, even. Can you clarify more about what you need to do with the
IPersist interface?

Typically, with the Framework in general and PowerShell in particular, you
instantiate the COM object using new-object, and then just access its public
methods and properties directly. The actual *COM* interfaces aren't intended
to be accessed. For some objects I've been able to use $obj.psbase to access
the underlying, unadapted object - what I usually get it the Framework's
interop class, though. The Framework doesn't really "like" to surface the
hardcore COM I* interfaces that you'd use in C++.

--
Don Jones
Windows PowerShell MVP
Founder: www.ScriptingAnswers.com
Co-Author: "Windows PowerShell: TFM"

"DouglasWoods" <DouglasWoods@discussions.microsoft.com> wrote in message
news:CAE0DCB9-F299-4CD4-B159-74366E6B81FD@microsoft.com...
>I have come from a C++ background where I have used the following to work
> with COM
>
> CComPtr<IBuilder> builder;
> builder.CoCreateInstance(__uuidof(Builder));
> CComQIPtr<IPersist> loader(builder);
>
> I can see how to use new-object -comobject to create the builder object,
> but
> how do I go about getting the IPersist interface?
>
> Is there a example/tutorial on using COM in Powershell?
> --
> Douglas Woods


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Querying for yesterday's events PowerShell
Re: querying wmi - recommended structure when iteration seems unnecessary? VB Script
Querying a file group on Exchange Server PowerShell
Powershell problem in querying some remote Windows 2003 servers PowerShell
Querying a number of servers for a specific Event ID -Remote? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46