public static bool IsApiAvailable(string libName, string procName)
    {
        bool value = false;

        if (!string.IsNullOrEmpty(libName) && !string.IsNullOrEmpty(procName))
        {
            Tuple <string, string> key = new Tuple <string, string>(libName, procName);
            if (availableApis.TryGetValue(key, out value))
            {
                return(value);
            }
            IntPtr intPtr = CommonUnsafeNativeMethods.LoadLibraryFromSystemPathIfAvailable(libName);
            if (intPtr != IntPtr.Zero)
            {
                IntPtr procAddress = CommonUnsafeNativeMethods.GetProcAddress(new HandleRef(value, intPtr), procName);
                if (procAddress != IntPtr.Zero)
                {
                    value = true;
                }
            }
            CommonUnsafeNativeMethods.FreeLibrary(new HandleRef(value, intPtr));
            availableApis[key] = value;
        }
        return(value);
    }
            /// <summary>
            /// Enters given Dpi awareness scope
            /// </summary>
            public DpiAwarenessScope(DpiAwarenessContext awareness)
            {
                if (EnableDpiChangedHighDpiImprovements)
                {
                    try
                    {
                        if (!CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(awareness, DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED))
                        {
                            originalAwareness = CommonUnsafeNativeMethods.GetThreadDpiAwarenessContext();

                            // If current process dpiawareness is SYSTEM_UNAWARE or SYSTEM_AWARE (must be equal to awareness), calling this method will be a no-op.
                            if (!CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(originalAwareness, awareness) &&
                                !CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(originalAwareness, DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNAWARE))
                            {
                                originalAwareness      = CommonUnsafeNativeMethods.SetThreadDpiAwarenessContext(awareness);
                                dpiAwarenessScopeIsSet = true;
                            }
                        }
                    }
                    catch (EntryPointNotFoundException)
                    {
                        dpiAwarenessScopeIsSet = false;
                    }
                }
            }
 /// <summary>
 /// resetting dpiawareness of the thread.
 /// </summary>
 private void ResetDpiAwarenessContextChanges()
 {
     if (dpiAwarenessScopeIsSet)
     {
         CommonUnsafeNativeMethods.TrySetThreadDpiAwarenessContext(originalAwareness);
         dpiAwarenessScopeIsSet = false;
     }
 }