public TXcnConnector() { this.myDelegate = new TXcnConnector.CallBack(this.MyCallBack); this.myDelegateEx = new TXcnConnector.CallBackEx(this.MyCallBackEx); if (Environment.Is64BitProcess) { if (!TXcnConnector.SetCallback64(this.myDelegate)) { throw new Exception("Could not establish a callback function"); } if (!TXcnConnector.SetCallbackEx64(this.myDelegateEx, IntPtr.Zero)) { throw new Exception("Could not establish a callback function"); } } else { if (!TXcnConnector.SetCallback(this.myDelegate)) { throw new Exception("Could not establish a callback function"); } if (!TXcnConnector.SetCallbackEx(this.myDelegateEx, IntPtr.Zero)) { throw new Exception("Could not establish a callback function"); } } TXcnConnector.instance = this; }
public string ConnectorInitialize(string Path, short LogLevel) { IntPtr num1 = MarshalUTF8.StringToHGlobalUTF8(Path); IntPtr num2 = new IntPtr(); IntPtr pData = !Environment.Is64BitProcess ? TXcnConnector.Initialize(num1, (int)LogLevel) : TXcnConnector.Initialize64(num1, (int)LogLevel); if (pData != IntPtr.Zero) { string str = MarshalUTF8.PtrToStringUTF8(pData); Marshal.FreeHGlobal(num1); if (Environment.Is64BitProcess) { TXcnConnector.FreeMemory64(pData); } else { TXcnConnector.FreeMemory(pData); } return(str); } else { Marshal.FreeHGlobal(num1); return(string.Empty); } }
public void MyCallBackEx(IntPtr pData, IntPtr userData) { string data = MarshalUTF8.PtrToStringUTF8(pData); if (Environment.Is64BitProcess) { TXcnConnector.FreeMemory64(pData); } else { TXcnConnector.FreeMemory(pData); } this.RaiseNewDataEvent(data); }
public TXcnConnector() { this.myDelegate = new TXcnConnector.CallBack(this.MyCallBack); this.myDelegateEx = new TXcnConnector.CallBackEx(this.MyCallBackEx); if (Environment.Is64BitProcess) { if (!TXcnConnector.SetCallback64(this.myDelegate)) throw new Exception("Could not establish a callback function"); if (!TXcnConnector.SetCallbackEx64(this.myDelegateEx, IntPtr.Zero)) throw new Exception("Could not establish a callback function"); } else { if (!TXcnConnector.SetCallback(this.myDelegate)) throw new Exception("Could not establish a callback function"); if (!TXcnConnector.SetCallbackEx(this.myDelegateEx, IntPtr.Zero)) throw new Exception("Could not establish a callback function"); } TXcnConnector.instance = this; }
public string ConnectorUnInitialize() { IntPtr num = new IntPtr(); IntPtr pData = !Environment.Is64BitProcess ? TXcnConnector.UnInitialize() : TXcnConnector.UnInitialize64(); if (!(pData != IntPtr.Zero)) { return(string.Empty); } string str = MarshalUTF8.PtrToStringUTF8(pData); if (Environment.Is64BitProcess) { TXcnConnector.FreeMemory64(pData); } else { TXcnConnector.FreeMemory(pData); } return(str); }
public string SendCommand(string command) { IntPtr num1 = MarshalUTF8.StringToHGlobalUTF8(command); IntPtr num2 = new IntPtr(); IntPtr pData = !Environment.Is64BitProcess ? TXcnConnector.SendCommand(num1) : TXcnConnector.SendCommand64(num1); if (!(pData != IntPtr.Zero)) { return(string.Empty); } string str = MarshalUTF8.PtrToStringUTF8(pData); Marshal.FreeHGlobal(num1); if (Environment.Is64BitProcess) { TXcnConnector.FreeMemory64(pData); } else { TXcnConnector.FreeMemory(pData); } return(str); }
private static bool SetCallbackEx64(TXcnConnector.CallBackEx pCallback, IntPtr userData);
private static bool SetCallback64(TXcnConnector.CallBack pCallback);