C#中怎么导出项目iphone qq文件导出

C/C++(10)
如何生成,调用和调试DLL工程
在使用其他语言调用C/C++程序,通常会使用DLL工程文件。本篇文章介绍的内容包括以下几点:
如何生成C/C++的DLL文件
如何在C#中调用DLL文件
如何调试DLL文件
如何生成C/C++的DLL文件
新建工程,选择“Visual C++”工程中的“Win32控制台程序”类型。工程设置中,将“应用程序类型”设置为“DLL”,“附加选项”设置为“空项目”。点击“完成”,则生产成了DLL工程文件。
这里以将C++类导出为DLL为例。类的头文件和源文件分别如下:
/**********************************************/
/**********************************************/
#ifdef DllDemoAPI
#define DllDemoAPI _declspec(dllimport)
class Point
void Print(int *x, int *y, int xSize, int ySize);
extern "C"
DllDemoAPI Point *Point_Create();
DllDemoAPI void Point_Print(Point *pt, int *x, int *y, int xSize, int ySize);
DllDemoAPI void Point_Delete(Point *pt);
/**********************************************/
/**********************************************/
#define DllDemoAPI _declspec(dllexport)
#include "DllTest.h"
#include &stdio.h&
extern "C"
DllDemoAPI Point* Point_Create()
return new Point();
DllDemoAPI void Point_Print(Point* pPoint, int *x, int *y, int xSize, int ySize)
return pPoint-&Print(x,y,xSize,ySize);
DllDemoAPI void Point_Delete(Point* pPoint)
void Point::Print(int *x,int *y, int xSize, int ySize)
for (int i = 0; i & xS i++)
printf("x[%d]=%d\n",i,x[i]);
for (int i = 0; i & yS i++)
printf("y[%d]=%d\n",i,y[i]);
代码中使用_declspec(dllimport)和_declspec(dllexport)进行DLL函数的导入和导出。
extern “C”的作用是使用C语言的编译逻辑导出函数,即函数名称则为定义的名称。而不会向C++一样给函数名加上前缀和后缀。
正是因为使用C语言的编译逻辑导出函数,所以无法对类直接进行导出,因为C语言不支持类。当然如果生成的DLL是给C++使用的,则不需要extern “C”关键字,也可以对类等C++支持的结构进行导出。
这里默认的调用是cdecl,如果需要使用stdcall或者fastcall进行调用,则需要另外进行声明。
如何在C#中调用DLL文件
在C#中调用C++的DLL有多种方法,例如使用Marshal模块, 托管DLL, COM组件等。这里介绍的是使用最常见的P/Invoke方法。
在C#中调用上述工程的代码如下:
using System.Collections.G
using System.Runtime.InteropS
using System.L
using System.T
namespace ConsoleApplication
class Program
[DllImport("DLLTest.dll", EntryPoint = "Point_Create", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Point_Create();
[DllImport("DLLTest.dll", EntryPoint = "Point_Print", CallingConvention = CallingConvention.Cdecl)]
public static extern void Point_Print(IntPtr value, int[] x, int[] y, int xSize, int ySize);
[DllImport("DLLTest.dll", EntryPoint = "Point_Delete", CallingConvention = CallingConvention.Cdecl)]
public static extern void Point_Delete(IntPtr value);
static void Main(string[] args)
IntPtr temp = Point_Create();
int[] x = new int[10];
int[] y = new int[10];
for (int i = 0; i & 10; i++)
int xSize = 10;
int ySize = 10;
Point_Print(temp, x, y, xSize, ySize);
Point_Delete(temp);
这里使用DllImport函数对DLL进行导入。
注意要将之前生成的DLL拷贝到exe文件所在的文件夹下。
如何调试DLL文件
在生成DLL的过程中,调试是必不可少的一步。调试的方式是写一个调用DLL中函数的工程,然后将该工程的exe文件设置为DLL工程的可执行文件即可。具体方法为在工程的属性页中,找到调试选项卡下的命令一行,然后将exe文件的路径添加进去,即可进行调试。
如何将多个类导出到一个DLL文件中
可以尝试使用托管DLL或COM组件的方法。
当类使用其他类中的功能时,如何生成DLL文件
在这种情况下,将调用到的其他类的文件添加到DLL生成的工程中,则生成的DLL就包含了调用类中的功能。无需进行其他特殊设置。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:16486次
排名:千里之外
原创:44篇
转载:25篇
(4)(1)(3)(1)(6)(6)(8)(4)(1)(18)(13)(2)(2)本帖子已过去太久远了,不再提供回复功能。温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(1445)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'C#项目打开/保存文件夹/指定类型文件,获取路径',
blogAbstract:'
1、打开文件路径:&&&&& &&&&&&&&&&& OpenFileDialog ofd = new OpenFileDialog();&&&&&&&&&&&&&&& //new一个方法&&&&&&&&&&& ofd.Filter = \"(*.*.*.xlsx)|*.*.*.xlsx|all|*.*\";&&&&&&&&&& //删选、设定文件显示类型&&&&&&&&&&&&ofd.ShowDialog();&&&&&&&&& //显示打开文件的窗口&&&&&&&&&&& string',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:5,
publishTime:5,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 iphone qq文件导出 的文章

 

随机推荐