예제 #1
0
        private void ReadDev()
        {
            const int DEV_REC_SIZE = 512;

            try
            {
                FileStream       fs           = File.Open(Path.Combine(GetRegistData(), "rawdev.lib"), FileMode.Open, FileAccess.Read);
                FileStream       fs1          = File.Open("output.txt", FileMode.Append, FileAccess.Write);
                StreamWriter     streamWriter = new StreamWriter(fs1, Encoding.UTF8);
                UCView.RawDevice rawDevice    = new UCView.RawDevice();
                byte[]           bytData      = new byte[Marshal.SizeOf(rawDevice)];
                for (int i = 1; i <= fs.Length / DEV_REC_SIZE - 1; i++)
                {
                    fs.Seek(i * DEV_REC_SIZE, SeekOrigin.Begin);
                    fs.Read(bytData, 0, bytData.Length);
                    rawDevice = rawDeserialize(bytData);
                    streamWriter.Write($"DeviceName:{rawDevice.szLibName},FactoryName:{rawDevice.szFactory},Clsid:{rawDevice.uuidDriver.ToString()}\n");
                    devList.Add(new DevItems()
                    {
                        Name    = rawDevice.szLibName,
                        Factory = rawDevice.szFactory,
                        guid    = rawDevice.uuidDriver,
                    });
                    streamWriter.Flush();
                }
                fs.Close();
                streamWriter.Close();
                fs1.Close();
            }
            catch
            {
                return;
            }
            // MessageBox.Show(rawDevice.uuidDriver.ToString());
        }
예제 #2
0
        private void WriteDev()
        {
            UCView.RawDevice rawDevice = new UCView.RawDevice()
            {
                szLibName  = "Device",
                szFactory  = "MyCompany",
                uuidDriver = new Guid("7F463566-1111-1111-1111-6D07A7E2008B"),
                type       = UCView.DT_MET,
                lLicence   = 0xA740DA53,
                szHelp     = ""
            };
            FileStream fs = File.Open("dev.lib", FileMode.Append, FileAccess.Write);

            byte[] bytData = rawSerialize(rawDevice);
            fs.Write(bytData, 0, bytData.Length);
            fs.Close();
        }