Exemple #1
0
        public static void GetCurrentThemeName(out string themeFileName, out string color, out string size)
        {
            StringBuilder stringBuilder     = new StringBuilder(260);
            StringBuilder stringBuilder1    = new StringBuilder(260);
            StringBuilder stringBuilder2    = new StringBuilder(260);
            HRESULT       currentThemeName1 = Standard.NativeMethods.GetCurrentThemeName_1(stringBuilder, stringBuilder.Capacity, stringBuilder1, stringBuilder1.Capacity, stringBuilder2, stringBuilder2.Capacity);

            currentThemeName1.ThrowIfFailed();
            themeFileName = stringBuilder.ToString();
            color         = stringBuilder1.ToString();
            size          = stringBuilder2.ToString();
        }
Exemple #2
0
        public static DWM_TIMING_INFO?DwmGetCompositionTimingInfo(IntPtr hwnd)
        {
            if (!Utility.IsOSVistaOrNewer)
            {
                return(null);
            }
            DWM_TIMING_INFO value = new DWM_TIMING_INFO
            {
                cbSize = Marshal.SizeOf(typeof(DWM_TIMING_INFO))
            };
            HRESULT hrLeft = NativeMethods._DwmGetCompositionTimingInfo(hwnd, ref value);

            if (hrLeft == HRESULT.E_PENDING)
            {
                return(null);
            }
            hrLeft.ThrowIfFailed();
            return(new DWM_TIMING_INFO?(value));
        }
Exemple #3
0
        private static Standard.IShellItem2 GetShellItemForPath(string path)
        {
            object obj2;

            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }
            Guid riid = new Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93");

            Standard.HRESULT hresult = Standard.NativeMethods.SHCreateItemFromParsingName(path, null, ref riid, out obj2);
            if ((hresult == ((Standard.HRESULT)Standard.Win32Error.ERROR_FILE_NOT_FOUND)) || (hresult == ((Standard.HRESULT)Standard.Win32Error.ERROR_PATH_NOT_FOUND)))
            {
                hresult = Standard.HRESULT.S_OK;
                obj2    = null;
            }
            hresult.ThrowIfFailed();
            return((Standard.IShellItem2)obj2);
        }
Exemple #4
0
        public static IShellItem2 GetShellItemForPath(string path)
        {
            object obj;

            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }
            Guid    guid = new Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93");
            HRESULT sOK  = NativeMethods.SHCreateItemFromParsingName(path, null, ref guid, out obj);

            if (sOK == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || sOK == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND)
            {
                sOK = HRESULT.S_OK;
                obj = null;
            }
            sOK.ThrowIfFailed();
            return((IShellItem2)obj);
        }
Exemple #5
0
        public static IShellItem2 GetShellItemForPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                // Internal function.  Should have verified this before calling if we cared.
                return(null);
            }

            Guid    iidShellItem2 = new Guid(IID.ShellItem2);
            object  unk;
            HRESULT hr = NativeMethods.SHCreateItemFromParsingName(path, null, ref iidShellItem2, out unk);

            // Silently absorb errors such as ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND.
            // Let others pass through
            if (hr == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || hr == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND)
            {
                hr  = HRESULT.S_OK;
                unk = null;
            }

            hr.ThrowIfFailed();

            return((IShellItem2)unk);
        }
Exemple #6
0
        public static DWM_TIMING_INFO?DwmGetCompositionTimingInfo(IntPtr hwnd)
        {
            DWM_TIMING_INFO?nullable;

            if (!Utility.IsOSVistaOrNewer)
            {
                nullable = null;
                return(nullable);
            }
            DWM_TIMING_INFO dWMTIMINGINFO = new DWM_TIMING_INFO()
            {
                cbSize = Marshal.SizeOf(typeof(DWM_TIMING_INFO))
            };
            DWM_TIMING_INFO dWMTIMINGINFO1 = dWMTIMINGINFO;
            HRESULT         hRESULT        = Standard.NativeMethods.DwmGetCompositionTimingInfo_1(hwnd, ref dWMTIMINGINFO1);

            if (hRESULT == HRESULT.E_PENDING)
            {
                nullable = null;
                return(nullable);
            }
            hRESULT.ThrowIfFailed();
            return(new DWM_TIMING_INFO?(dWMTIMINGINFO1));
        }