首先添加引用:
using Jungo.wdapi_dotnet;
using Jungo.yourapp_lib;
獲取PCI設備列表:
private YourApp_DeviceList pciDevList;//Declare PCI Device List
pciDevList = YourApp_DeviceList.TheDeviceList();//New
UInt32 dwStatus = pciDevList.Init();//Initilize Devices
if (dwStatus != (UInt32)WD_ERROR_CODES.WD_STATUS_SUCCESS)
return;
將列表添加到ComBox中:
foreach (YourApp_Device dev in pciDevList)
comboBox1.Items.Add(dev.ToString(true));
comboBox1.SelectedIndex = 0;
獲取指定設備:
YourApp_Device device;
YourApp_Device dev = pciDevList.Get(comboBox1.SelectedIndex);
UInt32 dwStatus = device.Open();
if (dwStatus != (UInt32)WD_ERROR_CODES.WD_STATUS_SUCCESS)
{
return false;
}
關閉設備:
bool bStatus = false;
if (device.Handle != IntPtr.Zero && !(bStatus = device.Close()))
{
return false;
}
else
device.Handle = IntPtr.Zero;
return bStatus;
獲取PCI BAR,並添加到ComBox中:
string[] sBars = device.AddrDescToString(false);
for (int i = 0; i < sBars.Length; ++i)
{
cmboBar.Items.Add(sBars[i]);
}
cmboBar.SelectedIndex = 0;