Пример #1
0
        public static API RshGetRegisteredDeviceName(uint index, out string value)
        {
            value = "";
            uint os;
            API  st = API.SUCCESS;

            Types.U16P tmp = new Types.U16P(0);
            try
            {
                os = Connector.UniDriverGetRegisteredDeviceName(index, ref tmp);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.Message.Contains("Unable to load DLL"))
                {
                    return((API)(os = (uint)API.UNIDRIVER_DLLWASNOTLOADED));
                }
                else
                {
                    return(API.UNDEFINED);
                }
            }
            st = (API)(os & MASK_RSH_ERROR);
            if (st == API.SUCCESS)
            {
                value = System.Runtime.InteropServices.Marshal.PtrToStringUni(tmp.data);
            }

            return(st);
        }
Пример #2
0
        public API Get(GET mode, out string value)
        {
            value = "";

            if (deviceHandle == IntPtr.Zero)
            {
                return(API.DEVICE_DLLWASNOTLOADED);
            }

            API st = API.SUCCESS;

            if (mode.ToString().Contains("UTF16"))
            {
                Types.U16P tmp = new Types.U16P(0);
                try
                {
                    operationStatus = Connector.UniDriverGet(deviceHandle, (uint)mode, ref tmp);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    if (ex.Message.Contains("Unable to load DLL"))
                    {
                        return((API)(operationStatus = (uint)API.UNIDRIVER_DLLWASNOTLOADED));
                    }
                    else
                    {
                        return(API.UNDEFINED);
                    }
                }
                st = (API)(operationStatus & MASK_RSH_ERROR);
                if (st == API.SUCCESS)
                {
                    value = System.Runtime.InteropServices.Marshal.PtrToStringUni(tmp.data);
                }
            }
            else
            {
                Types.S8P tmp = new Types.S8P(0);
                try
                {
                    operationStatus = Connector.UniDriverGet(deviceHandle, (uint)mode, ref tmp);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    if (ex.Message.Contains("Unable to load DLL"))
                    {
                        return((API)(operationStatus = (uint)API.UNIDRIVER_DLLWASNOTLOADED));
                    }
                    else
                    {
                        return(API.UNDEFINED);
                    }
                }
                st = (API)(operationStatus & MASK_RSH_ERROR);
                if (st == API.SUCCESS)
                {
                    value = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(tmp.data);
                }
            }

            return(st);
        }