110,545
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "windows.h"
#include "stdio.h"
using namespace std;
typedef int (*INIT)();
typedef int (WINAPI *BUS)(char*,char[]);
int main(int argc,char **argv)
{
HINSTANCE hDllInst = LoadLibrary("soft.dll");
INIT Init = (INIT)GetProcAddress(hDllInst, "INIT");
BUS Bus = (BUS)GetProcAddress(hDllInst, "BUSINESS_HANDLE");
char* input = "31";
char output[1024];
Init();
Bus(input,output);
cout<<output<<endl;
cin.get();
return 0;
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
/// <summary>
/// 初始化
/// </summary>
/// <returns></returns>
[DllImport("soft.dll")]
static extern int INIT();
/// <summary>
/// 接口
/// </summary>
/// <param name="inputData"></param>
/// <param name="outputData"></param>
/// <returns></returns>
[DllImport("soft.dll")]
static extern int BUSINESS_HANDLE(StringBuilder inputData, StringBuilder outputData);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
int i = INIT();
i = BUSINESS_HANDLE(new StringBuilder("31"), sb);//这一步出现问题
}
}
}