Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 private static bool SetCallbackEx64(TXcnConnector.CallBackEx pCallback, IntPtr userData);
Esempio n. 8
0
 private static bool SetCallback64(TXcnConnector.CallBack pCallback);