![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | [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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||