//Form1.cs内容: using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Text; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //申明DLL中函数 [DllImport("KB_Dll.dll", EntryPoint = "InputKey")] //不加密输入密码 private static extern int InputKey(string m_comm, string extCom, int time_out, int Cmd, StringBuilder Pwd);//不加密输入密码//[Out,MarshalAs(UnmanagedType.LPArray)] private void button1_Click(object sender, EventArgs e) { string m_comm = "USB_vid4754&pid9020"; string extCom="NULL"; int timeout=20; int Cmd; StringBuilder Pwd = new StringBuilder(300); Cmd = 1; int recv = 0; recv = InputKey(m_comm, extCom, timeout, Cmd, Pwd); MessageBox.Show(Pwd.ToString()); } private void Form1_Load(object sender, EventArgs e) { } } }
C#调用C++Dll例程
最新推荐文章于 2024-09-20 20:16:39 发布