我正在尝试使用VSPE api创建虚拟端口。
我尝试运行演示代码,没有出现错误-但这并没有为我创建端口。
知道为什么吗?
这是api指南: http://grzelewski.net/docs/VSPE/CCOMinterface.html
这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VSPELib;
namespace VSPE_API_Test
{
public partial class Form1 : Form
{
private VSPEApiClass vspe;
public Form1()
{
InitializeComponent();
vspe = new VSPEApiClass();
int result;
string activationKey = "SRBGMZSYPuIHWILsmLjF5CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPRJEEYxlJg + 4gdYguyYuMXkIPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9CDyBL3GQYD0IPIEvcZBgPQg8gS9xkGA9JyUaC2ZWE1DZV2 + wYWlRm7FFYrW3MDbZg8MkQsOQ8r1IPIEvcZBgPQg8gS9xkGA9LzrhjimHDiMlKqr6pSiw9CDl9n + 0bAgFr2ho7nXjCoTMHYzt4tsbEkJGNktLGVG42SZ63UbmIUNcKmfhSzXldVCLhfvZv3StR9c / vkYG471Nh62eC1qIYuBUvm + a3BK8iR0POD8w5ovtuYr0T8aQP3eh4b8lUwnPHG9NRJxerttq / +/ zX7c++9LDSQym3ThbWesK + A + X / vNw9qDgYt1dsJxDEEytsCRiT7bTiV5Djh1RlpIwETXWA089hiE9OYd7GpjKLq5dQOqSVcA3Fg1Wfdbqn / yn8q0 / AIDOd0iZlbVeLY68zKh1Di4gGEoa1kR8EOBp2mxeaFrfwUm3DsJ5Pc04f7aEw9XljfBUwl / bAs3LVH5HRii8lXZvUVvnnfpcQ == 1F250CF0960AE1C09E9450C816DE1232"; // <----- PUT ACTIVATION KEY HERE
// display VSPE API info
label1.Text = vspe.vspe_getVersionInformation();
// activate VSPE API
result = vspe.vspe_activate(activationKey);
// initialize API
result = vspe.vspe_initialize();
label2.Text = "Done!";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Info_Click_Click(object sender, EventArgs e)
{
// get devices count
int count = vspe.vspe_getDevicesCount();
string result = "Devices count: " + count.ToString() + "\n";
// enumerate devices
for (int i = 0; i < count; ++i)
{
// get device ID
int deviceId = vspe.vspe_getDeviceIdByIdx(i);
string name, initString;
int ok, used;
vspe.vspe_getDeviceInfo(deviceId, out name, out initString, out ok, out used);
result += name + " (" + initString + ") OK=" + ok.ToString() + "\n";
}
MessageBox.Show(result);
}
private void CreateDevice_Click(object sender, EventArgs e)
{
int result;
// Stop emulation
result = vspe.vspe_stopEmulation();
// Deatroy all devices
result = vspe.vspe_destroyAllDevices();
// Add Connector (COM9, no baud rate emulation)
result = vspe.vspe_createDevice("Connector", "9;0");
// Start emulation
result = vspe.vspe_startEmulation();
}
}
}
当我运行“信息”按钮时-我得到 设备数:0
谢谢,