예제 #1
0
        public static Atom FromExisting([NotNull] String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var atomId = GlobalAtomNativeMethods.GlobalFindAtom(name);

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

            return(new GlobalAtom(atomId, name));
        }
예제 #2
0
        public static String GetAtomName(UInt16 atomId)
        {
            if (atomId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(atomId));
            }

            var buffer = new StringBuilder(1024);
            var result = GlobalAtomNativeMethods.GlobalGetAtomName(atomId, buffer, buffer.Capacity);

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

            return(buffer.ToString());
        }
예제 #3
0
        public static Atom CreateNew(String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var existingGlobalAtom = GlobalAtomNativeMethods.GlobalFindAtom(name);

            if (existingGlobalAtom == 0)
            {
                existingGlobalAtom = GlobalAtomNativeMethods.GlobalAddAtom(name);
                if (existingGlobalAtom == 0)
                {
                    throw new Win32Exception();
                }

                return(new GlobalAtom(existingGlobalAtom, name));
            }

            throw new Win32Exception();
        }
예제 #4
0
 protected override void DeleteAtom(UInt16 atomid)
 {
     GlobalAtomNativeMethods.GlobalDeleteAtom(atomid);
 }