C# 中调用C++ DLL

时间:2012-05-10 09:50:36
【文件属性】:
文件名称:C# 中调用C++ DLL
文件大小:2.73MB
文件格式:RAR
更新时间:2012-05-10 09:50:36
C# C++ DLL 为了能用上原来的C++代码,只好研究下从C# 中调用DLL 首先必须要有一个声明,使用的是DllImport关键字: 包含DllImport所在的名字空间 using System.Runtime.InteropServices; public class XXXX{ [DllImport(“MyDLL.dll")] public static extern int mySum (int a,int b); } [DllImport(“MyDLL.dll")] public static extern int mySum (int a,int b); 代码中DllImport关键字作用是告诉编译器入口点在哪里,并将打包函数捆绑在这个类中 在调用的时候 在类中的时候 直接  mySum(a,b);就可以了 在其他类中调用: XXXX. mySum(a,b);
【文件预览】:
dll2
----dll2.dsw(516B)
----dll2.cpp(126B)
----dll2.opt(48KB)
----dll2.dsp(4KB)
----Debug()
--------dll2.pdb(625KB)
--------vc60.pdb(44KB)
--------vc60.idb(33KB)
--------dll2.pch(183KB)
--------dll2.exp(524B)
--------dll2.ilk(260KB)
--------dll2.dll(216KB)
--------dll2.obj(2KB)
--------dll2.lib(2KB)
----dll2.ncb(33KB)
----dll2.plg(1KB)
PInvoke.suo
PInvoke.sln
Dll
----Dll.ncb(41KB)
----Dll.plg(2KB)
----Debug()
--------vc60.pdb(52KB)
--------vc60.idb(33KB)
--------Dll.dll(216KB)
--------Dll.pch(183KB)
--------Dll.lib(2KB)
--------Dll.pdb(625KB)
--------Dll.ilk(261KB)
--------Dll.exp(519B)
----Dll.opt(53KB)
----Dll.dsw(514B)
----Dll.dsp(4KB)
----dll.h(61B)
----dll.cpp(207B)
PInvoke
----bin()
--------Debug()
----obj()
--------Debug()
----Dll.dll(216KB)
----Ivoke.cs(588B)
----PInvoke.csproj(4KB)
----Dll3.dll(196KB)
----Class1.cs(529B)
----App.ico(1KB)
----AssemblyInfo.cs(2KB)
----PInvoke.csproj.user(2KB)
standerMFC
----StdAfx.cpp(212B)
----standerMFC.clw(346B)
----standerMFC.def(196B)
----standerMFC.h(1KB)
----standerMFC.cpp(2KB)
----standerMFC.aps(18KB)
----Debug()
--------vc60.pdb(404KB)
--------standerMFC.exp(635B)
--------vc60.idb(233KB)
--------standerMFC.pdb(313KB)
--------standerMFC.pch(6.3MB)
--------StdAfx.obj(115KB)
--------standerMFC.obj(12KB)
--------standerMFC.lib(2KB)
--------standerMFC.ilk(128KB)
--------standerMFC.dll(100KB)
--------standerMFC.res(832B)
----standerMFC.dsp(4KB)
----standerMFC.opt(48KB)
----ReadMe.txt(3KB)
----standerMFC.dsw(528B)
----StdAfx.h(1KB)
----Resource.h(382B)
----standerMFC.rc(3KB)
----standerMFC.plg(1KB)
----res()
--------standerMFC.rc2(402B)
----standerMFC.ncb(41KB)

网友评论