Пример #1
0
        private static bool IsKnowledgeBase2533623OrGreater()
        {
            const string AddDllDirectoryName = nameof(AddDllDirectoryName);

            bool isKnowledgeBase2533623OrGreater = false;

            // We don't throw if one of these Win32 calls fail - we play it safe
            // and return false
            var hModule = IntPtr.Zero;

            if (UnsafeNativeMethods.GetModuleHandleEx(
                    UnsafeNativeMethods.GetModuleHandleFlags.None,
                    ExternDll.Kernel32,
                    out hModule) &&
                hModule != IntPtr.Zero)
            {
                try
                {
                    isKnowledgeBase2533623OrGreater =
                        UnsafeNativeMethods.GetProcAddressNoThrow(new HandleRef(null, hModule), AddDllDirectoryName) != IntPtr.Zero;
                }
                finally
                {
                    UnsafeNativeMethods.FreeLibrary(hModule);
                }
            }

            return(isKnowledgeBase2533623OrGreater);
        }