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 - [CTP2:] Add-Type Conundrum

Reply
 
Old 06-02-2008   #1 (permalink)
Jon


 
 

[CTP2:] Add-Type Conundrum

Hi

Thought this was a bit odd, so I figure I'll share it....

I'd have thought that these 2 would be virtually identical in terms of final
outcome -
the one being inline compiled c# and the other inline compiled VB, but it
would appear not.

# Inline c# Code
#----------------
$showWindowAsync = Add-Type -memberDefinition @"

[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

"@ -name "Win32ShowWindowAsync" -namespace
in32Functions -passThru -Language CSharp
#----------------

versus


# Inline VB.net Code
#----------------
$showWindowAsync = Add-Type -memberDefinition @"

<DllImport("user32.dll")> _
Public Shared Function ShowWindowAsync(ByVal hWnd As IntPtr, ByVal nCmdShow
As Integer) As Boolean
End Function

"@ -name "Win32ShowWindowAsync" -namespace
Win32Functions -passThru -Language VisualBasic
#----------------


The first c# example results in

PS (4) > $showWindowAsync

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False Win32ShowWindowAsync System.Object



whereas the VB example results in an array



PS (2) > $showWindowAsync

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False MyApplication
Microsoft.VisualBasic.Appli...
False False MyComputer
Microsoft.VisualBasic.Devic...
False False MyProject System.Object
False False MyWebServices System.Object
False False ThreadSafeObjectProvider`1 System.Object
True False Win32ShowWindowAsync System.Object



Nothing insurmountable of course, since they both include the all important
'Win32ShowWindowAsync', but curious nevertheless.


Any thoughts or insights?

--
Jon



My System SpecsSystem Spec
Old 06-02-2008   #2 (permalink)
Jon


 
 

Re: [CTP2:] Add-Type Conundrum

First example seemed to get chopped there. I'll try again ....


# Inline c# Code
#----------------
$showWindowAsync = Add-Type -memberDefinition @"

[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

"@ -name "Win32ShowWindowAsync" -namespace
Win32Functions -passThru -Language CSharp
#----------------


--
Jon

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
CTP2 PowerShell
q: save as dialogue conundrum Vista General
Vista installation conundrum Vista General
Cannot add to Favorites conundrum.... Vista General
A conundrum regarding mutliboot single computer (antivirus related) Vista General


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