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 - [V2] Add-type can not create Composite Struct ?

Reply
 
Old 10-26-2009   #1 (permalink)


XP
 
 

[V2] Add-type can not create Composite Struct ?

Hi,
I use Add-Type to create a composite struct :
Code:
add-type @"
using System;
using System.Runtime.InteropServices;
namespace mystruct
{
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public Int32 left;
        public Int32 top;
        public Int32 right;
        public Int32 bottom;
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct WINDOWINFO
    {
        public UInt32 cbSize;
        public RECT rcWindow;
        public RECT rcClient;
        public UInt32 dwStyle;
        public UInt32 dwExStyle;
        public UInt32 dwWindowStatus;
        public UInt32 cxWindowBorders;
        public UInt32 cyWindowBorders;
        public UInt16 atomWindowType;
        public UInt16 wCreatorVersion;
    }
}
"@
I can create a struct of type WindowInfo :
Code:
$w=new-object mystruct.windowinfo
$w
$w.wCreatorVersion=102
$w.wCreatorVersion 
#102
but i can not modify members of a property of type rect.
Code:
 
$w.rcClient
$w.rcClient.left=10
$w.rcClient.Left
#0
$r=new-object Mystruct.RECT
$r.left=12
$r.left
#12
$w.rcClient.left=$r.left
$w.rcClient.left
#0
$w.rcClient=$r
$w.rcClient.Left
#12
$w.rcClient.left=10
$w.rcClient.Left
#12
Is it a bug or not ?
Posh v2 Windows Seven Enterprise
Same problem with Posh v1 Windows XP Sp3 + C# Assembly

My System SpecsSystem Spec
Old 4 Weeks Ago   #2 (permalink)


XP
 
 

Re: [V2] Add-type can not create Composite Struct ?

Does anyone have an idea ?

[edit]
https://connect.microsoft.com/PowerS...dbackID=508717

Last edited by BatchMan; 4 Weeks Ago at 06:00 AM..
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to create a type of Task General Discussion
How to map openssl obtained private key parameters to RSAParameters struct members? .NET General
Is it possible to create a new type? PowerShell
Struct\Class Creation 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