Форум Beholder http://beholder.ru/bb/ | |
Работа с BeholdRC.dll в .NET (C#) http://beholder.ru/bb/viewtopic.php?f=10&t=9624 |
Страница 2 из 2 |
Автор: | Maxch5 [ 26 май 2012, 22:38 ] |
Заголовок сообщения: | Re: Работа с BeholdRC.dll в .NET (C#) |
Код для C# 2008 Я не стал перечислять все типы пультов и клавиш в связи с ненадобностью. К стандартным функциям добавлено: GetTV() - определяет состояние основной утилиты тюнера. Код: using System; using System.Runtime.InteropServices; namespace SSA_2._0// как и у основной формы { #region Типы ПДУ public enum RemoteType { Unknown = -1, Button30 = 0, Button28, Button34 } #endregion /* #region Кнопки для моего пульта public enum Button30 { NoButtonPressed = 0xFF, Button0 = 0x00, // Button 0 Button1 = 0x01, // Button 1 Button2 = 0x02, // Button 2 Button3 = 0x03, // Button 3 Button4 = 0x04, // Button 4 Button5 = 0x05, // Button 5 Button6 = 0x06, // Button 6 Button7 = 0x07, // Button 7 Button8 = 0x08, // Button 8 Button9 = 0x09, // Button 9 Recall = 0x0A, // Recall UpArrow = 0x0B, // Up arrow RightArrow = 0x0C, // Right arrow Mode = 0x0D, //Mode Sleep = 0x0E, //Sleep Audio = 0x0F, //Audio Info = 0x10, //Info TvAv = 0x11, //TV/AV Power = 0x12, //Power Mute = 0x13, //Mute Menu = 0x14, //Menu DownArrow = 0x15, //Down arrow Ok = 0x16, //OK MODE = 0x17, //mode LeftArrow = 0x18, //Left arrow ChanPlus = 0x1A, //Chan + VolPlus = 0x1B, //Vol + Function = 0x1C, //Function ChanMinus = 0x1E, //Chan - VolMinus = 0x1F, //Vol - } #endregion */ ////Кнопки пультов // // Old style 30 keys remote control unit // // -1 - No button pressed // 0 - Button 0 // 1 - Button 1 // 2 - Button 2 // 3 - Button 3 // 4 - Button 4 // 5 - Button 5 // 6 - Button 6 // 7 - Button 7 // 8 - Button 8 // 9 - Button 9 // 10 - Recall // 11 - Up arrow // 12 - Right arrow // 13 - Mode // 14 - Sleep // 15 - Audio // 16 - Info // 17 - TV/AV // 18 - Power // 19 - Mute // 20 - Menu // 21 - Down arrow // 22 - OK // 23 - +100 // 24 - Left arrow // 26 - Chan + // 27 - Vol + // 28 - Function // 30 - Chan - // 31 - Vol - // ///////////////////////////////////////////////////////////////////////////// // // Flat 28 keys remote control unit // // -1 - No button pressed // 0 - Button 0 // 1 - Button 1 // 2 - Button 2 // 3 - Button 3 // 4 - Button 4 // 5 - Button 5 // 6 - Button 6 // 7 - Button 7 // 8 - Button 8 // 9 - Button 9 // 10 - Recall // 11 - CH UP // 12 - VOL+ // 13 - Stereo // 14 - STOP // 15 - PREV // 16 - ZOOM // 17 - Source // 18 - Power // 19 - Mute // 21 - CH DOWN // 24 - VOL- // 25 - SNAPSHOT // 26 - NEXT // 27 - TIME SHIFT // 28 - FM Radio // 29 - REC // 30 - PAUSE // ///////////////////////////////////////////////////////////////////////////// // // New style 34 keys remote control unit // // -1 - No button pressed // 0 - Button 0 // 1 - Button 1 // 2 - Button 2 // 3 - Button 3 // 4 - Button 4 // 5 - Button 5 // 6 - Button 6 // 7 - Button 7 // 8 - Button 8 // 9 - Button 9 // 10 - Recall // 11 - Ch Up // 12 - Vol + // 13 - Info // 14 - Teletext // 15 - Record // 16 - Full screen // 17 - Mute // 18 - Power // 19 - Preview // 20 - Aspect // 21 - Ch Down // 22 - OK // 23 - Mode // 24 - Vol - // 25 - DVB // 26 - Stop // 27 - Play/Pause // 28 - TV/FM // 29 - Sleep // 30 - Source // 31 - Audio // 88 - Snapshot // 92 - Freeze // ///////////////////////////////////////////////////////////////////////////// public class BeholderRcApi { [DllImport("user32.dll", SetLastError = true)]//найти окно static extern IntPtr FindWindow(string lpClassName, string lpWindowName); //Проверяем запущена ли утилита тюнера public static int GetTV() { int a = 0;// не запущена if (FindWindow(null, "Behold TV: Режим ожидания").ToInt64() != 0) a = 1;// В режиме ожидания if (FindWindow("TMain", "BeholdTV").ToInt64() != 0) a = 2;// Работает return a; } [DllImport("BeholdRC.dll")] /// Возвращает общее количество WDM устройств видеозахвата. public static extern int GetCardCount(); [DllImport("BeholdRC.dll")] /// Возвращает имя устройства по индексу cardIndex. public static extern string GetCardName(int cardIndex); [DllImport("BeholdRC.dll")] /// Инициализирует устройство по индексу cardIndex. public static extern bool OpenCard(int cardIndex); [DllImport("BeholdRC.dll")] /// Возвращает код нажатой кнопки пульта ДУ Beholder. public static extern int GetRemoteCode(); [DllImport("BeholdRC.dll")] /// Возвращает код нажатой кнопки пульта ДУ Beholder. public static extern ulong GetRemoteCodeEx(); /*/// Возвращает код нажатой кнопки пульта ДУ Beholder. public static Button30 GetRemoteCode30() { return (Button30)GetRemoteCode(); }///*/ [DllImport("BeholdRC.dll")] /// Возвращает тип пульта ДУ для выбранного устройства. public static extern RemoteType GetRemoteType(); [DllImport("BeholdRC.dll")] /// Освобождает все ресурсы. public static extern bool UnInit(); } } перед использование необходимо инициализаровать: Код: bool isInitialized = BeholderRcApi.OpenCard(0);
|
Страница 2 из 2 | Часовой пояс: UTC + 3 часа |