Opc.Ua.Configuration.LocalSecurityPolicy.InitLsaString C# (CSharp) Method

InitLsaString() private static method

private static InitLsaString ( string s ) : LSA_UNICODE_STRING
s string
return LSA_UNICODE_STRING
        private static LSA_UNICODE_STRING InitLsaString(string s)
        {
            if (string.IsNullOrEmpty(s))
                return new LSA_UNICODE_STRING();

            // Unicode strings max. 32KB
            if (s.Length > 0x7ffe)
                throw new ArgumentException("String too long");
            LSA_UNICODE_STRING lus = new LSA_UNICODE_STRING();
            lus.Buffer = Marshal.StringToHGlobalUni(s);
            lus.Length = (UInt16)(s.Length * UnicodeEncoding.CharSize);
            lus.MaximumLength = (UInt16)((s.Length + 1) * UnicodeEncoding.CharSize);			
            return lus;
        }