Search results for 'DLL Import'. 1 post(s) found.
2007/08/26 21:33
How to call Visual C/C++ implemented DLL functions in C# - Simple DLLImport
2007/08/26 21:33 in C#

Managed world is beautiful, I have all classes I want in FrameWork.. But what if I want call some unmanaged code? For instance, I have DLL written in C++, and want use it from C#.
Let's look some code. Our DLL exports some function, in CDecl convention, that sums two integers:
extern "C" __declspec(dllexport) __cdecl int sum(int a,int b);
And, of course, we want reuse this code in C#. We must recall, that it is no "direct" way to call unmanaged code, but we must inform the compiler, what we want to call, how, and where is needed code located.
and now we can call it like normal C# function.[DLLImport("TestDll.dll", EntryPoint="sum",
ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
static extern int sum(int a,int b);
x=5;
y=7;
z=sum(x,y); // z will receive 12
Another posts included in "C#"
| Create PDF Files On the Fly In C Sharp (0) | 2007/08/27 |
| Queue Tutorial In C# (0) | 2007/08/27 |
| Stack Tutorial In C# (0) | 2007/08/27 |
| Send Email Using C# (0) | 2007/08/26 |
| How To Read And Write A Cookie (0) | 2007/08/26 |
| Using C# With Cookies (0) | 2007/08/26 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/25 08:44
moneyideas
-
Subject different money making ideas
2010/01/28 22:05
moneyideas
-
Subject different money making ideas
2010/01/29 06:30
moneyideas
-
Subject different money making ideas
2010/01/31 16:43
moneyideas
Prev

Rss Feed