LyncFellow.iBuddy.Init C# (CSharp) Метод

Init() публичный Метод

public Init ( string HidDevicePath ) : bool
HidDevicePath string
Результат bool
        public bool Init(string HidDevicePath)
        {
            SECURITY_ATTRIBUTES structure = new SECURITY_ATTRIBUTES();
            structure.lpSecurityDescriptor = 0;
            structure.bInheritHandle = Convert.ToInt32(true);
            structure.nLength = Marshal.SizeOf(structure);

            _hidFileHandle = CreateFile(HidDevicePath, 0xc0000000, 3, ref structure, 3, 0, 0);
            if (_hidFileHandle == -1)
            {
                return false;
            }

            _workerThread = new Thread(Worker);
            _workerThread.Start();

            IsAlive = true;
            return true;
        }

Usage Example

Пример #1
0
        public void RefreshList()
        {
            LastWin32Error = 0;

            var keys = new string[_buddies.Keys.Count];

            _buddies.Keys.CopyTo(keys, 0);
            foreach (var Key in keys)
            {
                var buddy = _buddies[Key];
                if (buddy.LastWin32Error != 0)
                {
                    LastWin32Error = buddy.LastWin32Error;
                }
                if (!buddy.IsAlive)
                {
                    buddy.Release();
                    _buddies.Remove(Key);
                }
            }

            List <string> devicePaths = new List <string>();

            devicePaths.AddRange(HIDDevices.Find((int)VendorID.TenxTechnology, (int)TenxTechDeviceID.iBuddy1));
            devicePaths.AddRange(HIDDevices.Find((int)VendorID.TenxTechnology, (int)TenxTechDeviceID.iBuddy2));
            foreach (var devicePath in devicePaths)
            {
                if (!_buddies.ContainsKey(devicePath))
                {
                    var buddy = new iBuddy();
                    if (buddy.Init(devicePath))
                    {
                        _buddies.Add(devicePath, buddy);
                    }
                }
            }
        }
All Usage Examples Of LyncFellow.iBuddy::Init