Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:)
Sergey Alexandrovich Kryukov 3-Jan-13 16:17pm    
As if everything else wasn't enough, you even abuse CodeProject...
Please, don't post your comments as solutions. You did it on this page, but what's outrageous, you also formally accepted your own "solution". What is that? Cheating? At least it looks like.

Please don't do it, all you can get is some down-votes and abuse report, something you don't want.

Thank you for your understanding.

Alexandre Bencz 4-Jan-13 5:43am    
Sorry... ;X
I do not remember more than I had done that ...

1 solution

Start with this :[^]

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;

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);

Step 6:
add this code in the "main" function which should have been generated in the default code file from step 3:


Step 7:

set a breakpoint on the above line

Step 8:

hit the F5 key.

Step 9:

Step into the code..
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900