public void Open(string driver = null, string device = null) { IntPtr driverPtr = IntPtr.Zero; IntPtr devicePtr = IntPtr.Zero; if (driver != null) { driverPtr = Marshal.StringToHGlobalAnsi(driver); } if (device != null) { devicePtr = Marshal.StringToHGlobalAnsi(device); } Out123.Errors error = Out123NativeMethods.Open(handle, driverPtr, devicePtr); if (driverPtr != IntPtr.Zero) { Marshal.FreeHGlobal(driverPtr); } if (devicePtr != IntPtr.Zero) { Marshal.FreeHGlobal(devicePtr); } if (error != Out123.Errors.OK) { throw new Out123.ErrorException(this); } }