Exemplo n.º 1
0
        public static Atom FromExisting([NotNull] String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var atomId = LocalAtomNativeMethods.FindAtom(name);

            if (atomId == 0)
            {
                throw new Win32Exception();
            }

            return(new LocalAtom(atomId, name));
        }
Exemplo n.º 2
0
        public static String GetAtomName(UInt16 atomId)
        {
            if (atomId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(atomId));
            }

            var buffer = new StringBuilder(1024);
            var result = LocalAtomNativeMethods.GetAtomName(atomId, buffer, buffer.Capacity);

            if (result == 0)
            {
                throw new Win32Exception();
            }

            return(buffer.ToString());
        }
Exemplo n.º 3
0
        public static Atom CreateNew(String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var existingLocalAtom = LocalAtomNativeMethods.FindAtom(name);

            if (existingLocalAtom == 0)
            {
                existingLocalAtom = LocalAtomNativeMethods.AddAtom(name);
                if (existingLocalAtom == 0)
                {
                    throw new Win32Exception();
                }

                return(new LocalAtom(existingLocalAtom, name));
            }

            throw new Win32Exception();
        }
Exemplo n.º 4
0
 protected override void DeleteAtom(UInt16 atomid)
 {
     LocalAtomNativeMethods.DeleteAtom(atomid);
 }