コード例 #1
0
        protected virtual Boolean Set(String key, String value, String section)
        {
            if (WritePrivateProfileString(section, key, value, Path) == 0)
            {
                InteropUtils.ThrowLastWin32Exception();
            }

            return(true);
        }
コード例 #2
0
        public static DiskSpace DriveFreeBytes(String path)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (!path.EndsWith("\\"))
            {
                path += '\\';
            }

            if (!GetDiskFreeSpaceEx(path, out UInt64 free, out UInt64 total, out UInt64 totalfree))
            {
                InteropUtils.ThrowLastWin32Exception();
            }

            return(new DiskSpace(path, total, totalfree, free));
        }
コード例 #3
0
        public static MonitorInfo GetMonitorInfoFromWindow(IntPtr handle, DefaultMonitorType type)
        {
            if (handle == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            IntPtr monitor = MonitorFromWindow(handle, (UInt32)type);

            if (monitor == IntPtr.Zero)
            {
                InteropUtils.ThrowLastWin32Exception();
            }

            MonitorInfo screen = new MonitorInfo();

            if (!GetMonitorInfo(monitor, screen))
            {
                InteropUtils.ThrowLastWin32Exception();
            }

            return(screen);
        }