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()); */ }
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); }