Access Volumn via extern and invoke win 32 dll

 const int SupportsCompression = 0x10;
        const int SupportEncryption = 0x20000;

        [DllImport("Kernel32.dll", SetLastError = true)]
        extern static bool GetVolumeInformation(string vol, StringBuilder name, int nameSize, out uint serialNum,
            out uint maxNameLen, out uint flags, StringBuilder fileSysName, int fileSysNameSize);

 static void GetVolumeInfoDemo()
        {
            uint serialNum, maxNameLen, flags;
            bool ok = GetVolumeInformation(@"C:\", null, 0, out serialNum, out maxNameLen, out flags, null, 0);
            if(!ok)
            {
                throw new Win32Exception();
            }
            bool canCompress = (flags & SupportsCompression) != 0;
            Console.WriteLine($"canCompress:{canCompress}");
            bool canEncrypt = (flags & SupportEncryption) != 0;
            Console.WriteLine($"canEncrypt:{canEncrypt}");
        }

 

上一篇:《ENAS:Efficient Neural Architecture Search via Parameter Sharing》论文笔记


下一篇:Error executing DDL "drop sequence if exists hibernate_sequence" via JDBC Statement