// open device; mode is selected depending on state of NativeData // => see OpenNative() and OpenPAnsiChar() private bool OpenIRCom() { UpdateForm update = new UpdateForm(MainForm.UpdateMessageBox); try { if (NativeMode == true) { Native = new dlgtNative(MyCallBackNative); return(InitNative(Native)); } else { PAnsiChar = new dlgtPAnsiChar(MyCallBackPAnsiChar); return(InitPAnsiChar(PAnsiChar)); } } catch (DllNotFoundException) { MainForm.Invoke(update, true, String.Format("ERROR: unable to find DLL '{0}'!\r\n", USB_IRRR_DllName)); return(false); } catch (SEHException) { MainForm.Invoke(update, true, String.Format("ERROR: SEHException occured!\r\nRestart the application to change the mode or use a DLL version above 1.0.0.10.")); return(false); } }
// method to close device and to delete references public bool CloseDevice() { try { if (NativeMode) { Native = null; return(InitNative(null)); } else { PAnsiChar = null; return(InitPAnsiChar(null)); } } catch //(DllNotFoundException) { return(false); } }
private static extern bool InitNative(dlgtNative dlgt);