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

_GUID (Structures)
 
.
Summary
TODO - a short description

C# Definition:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct GuidStruct
    {
        internal UInt32 Data1;
        internal UInt16 Data2;
        internal UInt16 Data3;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        internal byte[] Data4;

        internal GuidStruct Initialize()
        {
        Data4 = new byte[8];
          return this;
        }
        internal GuidStruct Initialize(string guid)
        {
        Data4 = new byte[8];
        ConvertirToGuidStruct(guid);
        return this;
        }

        internal void ConvertToGuidStruct(string guid)
        {
        string[] guidTab = guid.Split(new char[] { ':', '-' });
        if (guidTab.Length == 5)
        {
            this.Data1 = Convert.ToUInt32(guidTab[0], 16);
            this.Data2 = Convert.ToUInt16(guidTab[1], 16);
            this.Data3 = Convert.ToUInt16(guidTab[2], 16);
            byte[] data4Part1 = BitConverter.GetBytes(Convert.ToInt16(guidTab[3], 16));
            byte[] data4Part2 = BitConverter.GetBytes(Convert.ToInt64(guidTab[4], 16));

            if (data4Part1.Length == 2 && data4Part2.Length == 8)
            {
            this.Data4[0] = data4Part1[0];
            this.Data4[1] = data4Part1[1];
            this.Data4[2] = data4Part2[0];
            this.Data4[3] = data4Part2[1];
            this.Data4[4] = data4Part2[2];
            this.Data4[5] = data4Part2[3];
            this.Data4[6] = data4Part2[4];
            this.Data4[7] = data4Part2[5];
            }
        }
        }

        internal string ConvertToString()
        {
        string guid;

        guid = Data1.ToString("x").PadLeft(8, '0');
        guid += "-" + Data2.ToString("x").PadLeft(4, '0');
        guid += "-" + Data3.ToString("x").PadLeft(4, '0');
        guid += "-" + BitConverter.ToInt16(new byte[] { Data4[0], Data4[1] }, 0).ToString("x");
        guid += "-" + BitConverter.ToInt64(new byte[] { Data4[2], Data4[3], Data4[4], Data4[5], Data4[6], Data4[7], 0, 0 }, 0).ToString("x");
        return guid;
        }
    }

VB Definition:

Structure _GUID
   Public TODO
End Structure

User-Defined Field Types:

None.

Notes:

None.

Documentation
_GUID on MSDN

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
Find References
Show Printable Version
Revisions