Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

UNICODE_STRING (Structures)
 
.
Summary
The UNICODE_STRING structure is used to define Unicode strings.

C# Definition:

[StructLayout(LayoutKind.Sequential)]
public struct UNICODE_STRING : IDisposable
{
   public ushort Length;
   public ushort MaximumLength;
   private IntPtr buffer;

   public UNICODE_STRING(string s)
   {
     Length = (ushort)(s.Length * 2);
     MaximumLength = (ushort)(Length + 2);
     buffer = Marshal.StringToHGlobalUni(s);
   }

   public void Dispose()
   {
     Marshal.FreeHGlobal(buffer);
     buffer = IntPtr.Zero;
   }

   public override string ToString()
   {
     return Marshal.PtrToStringUni(buffer);
   }
}

VB.NET Definition:

<StructLayout(LayoutKind.Sequential)> _
Private Structure UNICODE_STRING
    Public Length As UShort
    Public MaximumLength As UShort
    <MarshalAs(UnmanagedType.LPWStr)> _
    Private buffer As String

    Public Sub New(s As String)
       Length = CUShort(s.Length * 2)
       MaximumLength = CUShort(Length + 2)
       buffer = s
    End Sub

    Public Overrides Function ToString() As String
       Return buffer
    End Function
End Structure

User-Defined Field Types:

None.

Notes:

None.

Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions