111,129
社区成员
发帖
与我相关
我的任务
分享
// mySum.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
extern "C" _declspec(dllexport) char *mySum(char *a, char **b)
{
printf((*b),"%s",a);
return *b;
}
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 TestDLL
{
public partial class Form1 : Form
{
[DllImport("MySum.dll", EntryPoint = "mySum", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern string mySum(string a, ref string b);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string b = "";
mySum("1234", ref b);
}
}
}