読者です 読者をやめる 読者になる 読者になる

のねのBlog

パソコンやソフト開発で起きた問題など書きます。よろしくお願いします。

LPArrayとByValArrayの違い

ByValArrayは、SizeConst必須、ArraySubTypeオプション。

ByValArray	

When the MarshalAsAttribute.Value property is set to ByValArray, 
the SizeConst field must be set to indicate the number of elements in the array.

The ArraySubType field can optionally contain the UnmanagedType of the array elements
 when it is necessary to differentiate among string types. 

You can use this UnmanagedType only on an array that whose elements appear as fields in a structure.

LPArrayの場合:

managed => unmanagedは、マネージド配列から長さが決まる。

unmanaged => managedは、SizeConst,SizePAramIndexで決まる。

LPArray	

A pointer to the first element of a C-style array. 

When marshaling from managed to unmanaged code,
 the length of the array is determined by the length of the managed array. 

When marshaling from unmanaged to managed code, 
the length of the array is determined from the MarshalAsAttribute.SizeConst and MarshalAsAttribute.SizeParamIndex fields, 

optionally followed by the unmanaged type of the elements within the array 
when it is necessary to differentiate among string types.