📄 formmain.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace GetDevicesInfo
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// 最多返回三个红外设备的信息
IrDAClient irClient = new IrDAClient();
IrDADeviceInfo[] irDevices = irClient.DiscoverDevices(2);
// 如果没有发现红外设备则给出提示
if (irDevices.Length == 0)
{
MessageBox.Show("No remote infrared devices found!");
return;
}
// 将获得的红外设备信息列举出来
string device;
int ID;
listBox1.Items.Clear();
foreach (IrDADeviceInfo irDevice in irDevices)
{
ID = BitConverter.ToInt32(irDevice.DeviceID, 0);
device = ID.ToString() + " " + irDevice.DeviceName + " "
+ irDevice.CharacterSet + " " + irDevice.Hints;
listBox1.Items.Add(device);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -