コード例 #1
0
ファイル: Out123.cs プロジェクト: luca1337/aiv-mpg123
        public void DriverInfo()
        {
            IntPtr driverPtr = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>());
            IntPtr devicePtr = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>());

            Out123.Errors error = Out123NativeMethods.DriverInfo(handle, driverPtr, devicePtr);
            Console.WriteLine(error);
            Console.WriteLine(LastErrorCode());
            Console.WriteLine(LastErrorString());

            if (error != Out123.Errors.OK)
            {
                throw new Out123.ErrorException(error);
            }

            /*
             * IntPtr driver = Marshal.ReadIntPtr(driverPtr);
             * IntPtr device = Marshal.ReadIntPtr(devicePtr);
             *
             * Console.WriteLine(driver.ToString());
             * Console.WriteLine(device.ToString());
             */
        }
コード例 #2
0
ファイル: Out123.cs プロジェクト: fdefelici/aiv-mpg123
        public Out123.DriverInfo GetDriverInfo()
        {
            IntPtr driverPtr = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>());
            IntPtr devicePtr = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>());

            Out123.Errors error = Out123NativeMethods.DriverInfo(handle, driverPtr, devicePtr);

            if (error != Out123.Errors.OK)
            {
                Marshal.FreeHGlobal(driverPtr);
                Marshal.FreeHGlobal(devicePtr);
                throw new Out123.ErrorException(error);
            }

            IntPtr driver = Marshal.ReadIntPtr(driverPtr);
            IntPtr device = Marshal.ReadIntPtr(devicePtr);

            Out123.DriverInfo result = new Out123.DriverInfo(Marshal.PtrToStringAnsi(driver), Marshal.PtrToStringAnsi(device));
            Marshal.FreeHGlobal(driverPtr);
            Marshal.FreeHGlobal(devicePtr);

            return(result);
        }