C ++/CLI中的DLL [英] DLL in C++/CLI
问题描述
您好,我想,如果有人可以在C ++/CLI中发布一个DLL的简单示例,以及如何在C ++/CLI中使用它.
不必太复杂,是的,很简单,例如我在控制台中键入一个值,该值将移至dll,并返回一个加,乘或除的值...
如果有人可以帮助我,我将不胜感激:)
Hello, I would like, if someone can post a simple example of a DLL in C++/CLI, and how to use it, also in C++/CLI.
Need not be complex, and yes, something simple, like I type a value in the console, this value goes to the dll, and returns a value added, or multiplied, or divided...
I am grateful if someone can help me:)
推荐答案
从以下内容开始: ^ ]
步骤1:
在Visual Studio中创建一个为DLL项目(C ++)的项目
步骤2:
将此代码添加到它添加的默认代码文件中:
Start with this : http://msdn.microsoft.com/en-us/library/a90k134d(VS.80).aspx[^]
Step 1:
create a project in Visual Studio that is a DLL project (C++)
Step 2:
add this code to the default code file it adds:
__declspec(dllexport) int doSomething(int value)
{
return value * 5;
}
步骤3:
在Visual Studio中添加另一个项目,该项目是控制台应用程序(c ++)
步骤4:
将项目引用添加到在步骤1中创建的项目.
步骤5:
将此代码添加到从步骤3添加的默认代码文件中(在"main"功能之上)
Step 3:
add another project in Visual Studio that is a Console App (c++)
Step 4:
add a project reference to the project created in Step 1.
Step 5:
add this code to the default code file that is added from Step 3: (above the "main" function)
__declspec(dllimport) int doSomething(int value);
步骤6:
将此代码添加到应该在步骤3的默认代码文件中生成的"main"函数中.
Step 6:
add this code in the "main" function which should have been generated in the default code file from step 3:
doSomething(11);
步骤7:
在上述行上设置断点
步骤8:
按F5键.
步骤9:
进入代码..
Step 7:
set a breakpoint on the above line
Step 8:
hit the F5 key.
Step 9:
Step into the code..
这篇关于C ++/CLI中的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!