7,540
社区成员
发帖
与我相关
我的任务
分享
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
#include "Win32Project1.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//Win32Project1.h
#ifdef WIN32PROJECT1_EXPORTS
#define WIN32PROJECT1_API __declspec(dllexport)
#else
#define WIN32PROJECT1_API __declspec(dllimport)
#endif
#include<iostream>
using namespace std;
// 此类是从 Win32Project1.dll 导出的
class WIN32PROJECT1_API CWin32Project1 {
public:
string t(string equation);
};
// Win32Project1.cpp : 定义 DLL 应用程序的导出函数。
#include "stdafx.h"
#include "Win32Project1.h"
// 这是已导出类的构造函数。
// 有关类定义的信息,请参阅 Win32Project1.h
string CWin32Project1::t(string equation) {
string solution = equation + " is success!!!";
return solution;
}
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 System.Runtime.InteropServices;
using System.Reflection;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
String equation;
String solution;
[DllImport("Win32Project1.dll")]
public extern static string t(string equation);
*********过于复杂,与题无关,不阐述******
solution = t(equation);
************
}
}