// cppdll.cpp : 定義DLL 應用程式的進入點。
//
#include "stdafx.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" __declspec(dllexport) double add(double,double);
double __declspec(dllexport) add(double a,double b)
{
return a+b;
}
#ifdef _MANAGED
#pragma managed(pop)
#endif
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace rehserh
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("cppdll.dll")]
public static extern float add(double x, double y);
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = add(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text)).ToString();
}
}
}
沒有留言:
張貼留言
您的留言會先經過審核後才會公開至版面上
若本站所分享的資訊對您有幫助或有幫您省到錢的話
麻煩在留完言之後順手幫個忙
瀏覽一些您有興趣的廣告連結當作回饋贊助
您的小小鼓勵是支持本站繼續分享的最大動力
謝謝各位善心人士!! :)