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