Home All Groups Group Topic Archive Search About

Problems With Struct

Author
19 Mar 2006 3:15 AM
David White
I have the following structure. I need to create a pointer to it for calling
the Windows API. When I try, I get an error. I have found that the String is
the culprit. In the C declaration for this structure, the String is shown as
UNICODE_STRING. Can someone tell me the correct datatype to use for the String
which will allow me to both call the Win API and declare a pointer to this
structure? Thanks.

     [StructLayout(LayoutKind.Sequential)]
     struct OBJECT_TYPE_INFORMATION
     {
         public String TypeName;
         public uint TotalNumberOfObjects;
         public uint TotalNumberOfHandles;
         public uint TotalPagedPoolUsage;
         public uint TotalNonPagedPoolUsage;
         public uint TotalNamePoolUsage;
         public uint TotalHandleTableUsage;
         public uint HighWaterNumberOfObjects;
         public uint HighWaterNumberOfHandles;
         public uint HighWaterPagedPoolUsage;
         public uint HighWaterNonPagedPoolUsage;
         public uint HighWaterNamePoolUsage;
         public uint HighWaterHandleTableUsage;
         public uint InvalidAttributes;
         public GENERIC_MAPPING GenericMapping;
         public uint ValidAccessMask;
         public bool SecurityRequired;
         public bool MaintainHandleCount;
         public uint PoolType;
         public uint DefaultPagedPoolCharge;
         public uint DefaultNonPagedPoolCharge;
     }

Author
19 Mar 2006 1:03 PM
Mattias Sjögren
David,

>I have found that the String is
>the culprit. In the C declaration for this structure, the String is shown as
>UNICODE_STRING.

Exactly, UNICODE_STRING is defined as

typedef struct _LSA_UNICODE_STRING { 
    USHORT Length; 
    USHORT MaximumLength; 
    PWSTR Buffer;
} LSA_UNICODE_STRING,

so that's what you have to match.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

AddThis Social Bookmark Button