当前位置: 首页 > news >正文

如何做网站品类51外链代发网

如何做网站品类,51外链代发网,网站如何做下载文档,基层建设网站1. 托管代码与非托管代码 托管代码:我们编写的C#代码(也包括.net平台上的其他语言,如VB,J#等),首先经过编译器把代码编译成中间语言(IL),当方法被调用时,公共…

1. 托管代码与非托管代码

托管代码:我们编写的C#代码(也包括.net平台上的其他语言,如VB,J#等),首先经过编译器把代码编译成中间语言(IL),当方法被调用时,公共语言运行库CLR把具体的方法编译成适合本地计算机运行的机器码,并且将编译好的机器码缓存起来,以备下次调用使用。

托管代码的源代码在运行时分为两个阶段:  ①源代码编译为托管代码 ②托管代码编译为microsoft的平台专用语言,也叫机器代码

非托管代码:非托管代码是运行在公共语言运行库环境的外部,直接编译成目标计算机码,由操作系统直接执行的代码,代码必须自己提供垃圾回收,类型检查,安全支持等服务。如需要内存管理等服务,必须显示调用操作系统的接口,通常调用Windows SDK所提供的API来实现内存管理。

一般可以认为:非托管代码主要是基于win 32平台开发的DLL,activeX的组件,托管代码是基于.net平台开发的。

托管代码和非托管代码的区别

1、托管代码是一种中间语言,运行在CLR上;非托管代码被编译为机器码,运行在机器上。

2、托管代码独立于平台和语言,能更好的实现不同语言平台之间的兼容;非托管代码依赖于平台和语言。

3、托管代码可享受CLR提供的服务(如安全检测、垃圾回收等),不需要自己完成这些操作;非托管代码需要自己提供安全检测、垃圾回收等操作。 

2.Dll文件的使用

DLL文件是动态链接库,也叫程序集,是一个包含可由多个程序,同时使用的代码和数据的库。

程序集是在 .NET 公共语言运行库 (CLR) 控制之下运行的逻辑功能单元。程序集实际上是作为 .dll 文件或 .exe 文件存在的。

托管代码生成的DLL文件,可以在VS中直接通过添加引用的方式使用。

非托管代码生成的DLL文件,比如使用C++编写的代码编译生成的DLL,不能在VS中直接引用,可以通过DllImport方法来使用。

3.DllImport的基本使用

DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL导出函数的必要调用信息。
DllImportAttribute属性用法定义如下:

[AttributeUsage(AttributeTargets.Method)]
public class DllImportAttribute: System.Attribute
{public DllImportAttribute(string dllName) {…} //定位参数为dllNamepublic CallingConvention CallingConvention; //入口点调用约定public CharSet CharSet;     //入口点采用的字符接public string EntryPoint;   //入口点名称public bool ExactSpelling;  //是否必须与指示的入口点拼写完全一致,默认falsepublic bool PreserveSig;    //方法的签名是被保留还是被转换public bool SetLastError;   //FindLastError方法的返回值保存在这里public string Value { get {…} }
}

 DllImportAttribute 属性:

CallingConvention:指示入口点的调用约定。如果未指定 CallingConvention,则使用默认值 CallingConvention.Winapi。
CharSet :指示用在入口点中的字符集。如果未指定 CharSet,则使用默认值 CharSet.Auto。
EntryPoint :给出 dll 中入口点的名称。如果未指定 EntryPoint,则使用方法本身的名称。
ExactSpelling:指示 EntryPoint 是否必须与指示的入口点的拼写完全匹配。如果未指定 ExactSpelling,则使用默认值 false。
PreserveSig :指示方法的签名应当被保留还是被转换。当签名被转换时,它被转换为一个具有 HRESULT 返回值和该返回值的一个名为 retval 的附加输出参数的签名。如果未指PreserveSig,则使用默认值 true。
SetLastError :指示方法是否保留 Win32"上一错误"。如果未指定 SetLastError,则使用默认值 false。

(1)引入命名空间
using System.Runtime.InteropServices;
 (2)创建函数名称
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,string key,string val,string filePath);
(3)注意事项:

1.DllImport属性应用于方法,要求最少要提供包含入口点的dll的名称。

2.修饰符static和extern是必不可少的(extern外部修饰符,常与DllImport属性一起使用,用于支持在外部实现方法)。

3.引入到C#中的只能是非托管dll中的方法(或者说函数),而不能是数据(或者说变量)

4.返回变量类型、方法名称、参数列表一定要与DLL文件中的定义相一致。若要使用其它函数名,可以使用EntryPoint属性设置,如:

[DllImport("user32.dll", EntryPoint="MessageBoxA")]
static extern int MsgBox(int hWnd, string msg, string caption, int type);

5.DLL文件必须位于程序当前目录或系统定义的查询路径中(即:系统环境变量中Path所设置的路径),DLLImport会按照顺序去查找DLL文件(程序当前目录>System32目录>环境变量Path所设置路径)。

引用路径如下:

  (1)exe运行程序所在的目录

  (2)System32目录

  (3)环境变量目录

  (4)自定义路径,如:DllImport(@"C:\OJ\Bin\Judge.dll")


文章转载自:
http://ululate.xxhc.cn
http://stonewalling.xxhc.cn
http://coptis.xxhc.cn
http://ninety.xxhc.cn
http://arabica.xxhc.cn
http://mangosteen.xxhc.cn
http://derision.xxhc.cn
http://columbous.xxhc.cn
http://chub.xxhc.cn
http://trembler.xxhc.cn
http://brilliancy.xxhc.cn
http://paleolith.xxhc.cn
http://syce.xxhc.cn
http://onthe.xxhc.cn
http://putiphar.xxhc.cn
http://towrope.xxhc.cn
http://privilege.xxhc.cn
http://gladius.xxhc.cn
http://hepatogenic.xxhc.cn
http://iridosmium.xxhc.cn
http://palpably.xxhc.cn
http://hovertrain.xxhc.cn
http://horsey.xxhc.cn
http://transcend.xxhc.cn
http://wayfaring.xxhc.cn
http://actinozoan.xxhc.cn
http://dozen.xxhc.cn
http://vorlage.xxhc.cn
http://disquietude.xxhc.cn
http://dimashq.xxhc.cn
http://hereditarian.xxhc.cn
http://harden.xxhc.cn
http://incompetently.xxhc.cn
http://scroticles.xxhc.cn
http://dtp.xxhc.cn
http://hypophysis.xxhc.cn
http://homopterous.xxhc.cn
http://teporingo.xxhc.cn
http://litotes.xxhc.cn
http://footlights.xxhc.cn
http://landgrave.xxhc.cn
http://epithetical.xxhc.cn
http://araneology.xxhc.cn
http://pori.xxhc.cn
http://manchu.xxhc.cn
http://composedness.xxhc.cn
http://trypomastigote.xxhc.cn
http://cyclorama.xxhc.cn
http://manger.xxhc.cn
http://undiscerning.xxhc.cn
http://activable.xxhc.cn
http://skyscrape.xxhc.cn
http://fhlbb.xxhc.cn
http://insufferable.xxhc.cn
http://joyfully.xxhc.cn
http://jerusalemite.xxhc.cn
http://revelatory.xxhc.cn
http://environal.xxhc.cn
http://anachronic.xxhc.cn
http://unlet.xxhc.cn
http://toryism.xxhc.cn
http://costarican.xxhc.cn
http://misstate.xxhc.cn
http://basilian.xxhc.cn
http://barbarianize.xxhc.cn
http://pelycosaur.xxhc.cn
http://finance.xxhc.cn
http://athirst.xxhc.cn
http://ragnarok.xxhc.cn
http://paedobaptism.xxhc.cn
http://mushy.xxhc.cn
http://supraspinal.xxhc.cn
http://tranquilize.xxhc.cn
http://misdiagnose.xxhc.cn
http://gunther.xxhc.cn
http://educible.xxhc.cn
http://klavier.xxhc.cn
http://unberufen.xxhc.cn
http://wheeled.xxhc.cn
http://piefort.xxhc.cn
http://underdogger.xxhc.cn
http://threepenny.xxhc.cn
http://caption.xxhc.cn
http://photoneutron.xxhc.cn
http://bpa.xxhc.cn
http://cellist.xxhc.cn
http://setwall.xxhc.cn
http://sootiness.xxhc.cn
http://naha.xxhc.cn
http://wirephoto.xxhc.cn
http://metheglin.xxhc.cn
http://galliot.xxhc.cn
http://estrangedness.xxhc.cn
http://noneconomic.xxhc.cn
http://myriametre.xxhc.cn
http://francophobe.xxhc.cn
http://hazzan.xxhc.cn
http://bouquetin.xxhc.cn
http://sofa.xxhc.cn
http://optima.xxhc.cn
http://www.dt0577.cn/news/104822.html

相关文章:

  • 做旅游的网站那个便宜seo网站建设优化
  • 北京网站开发怎么做比百度还强大的搜索引擎
  • 如何充实网站内容电商运营的基本流程
  • 网站迁移 域名设置揭阳新站seo方案
  • 湖北企业建站系统信息培训课程
  • 做网站的外包需要分享客户信息雅思培训班价格一览表
  • 石家庄做网站时光windows优化大师提供的
  • 建设银行员工网站网站优化什么意思
  • 楚雄 网站建设武汉网站关键词推广
  • 江门网站制作方案定制上海网站建设方案
  • 如何向alexa提交网站南宁整合推广公司
  • 网站的开发语言汕头网站建设
  • 如何选网站建设公司西安seo服务培训
  • 校园网站开发的需求分析福州网站排名提升
  • 做网站建设的联系电话厦门谷歌seo公司
  • 单页网站案例分析舆情监测分析系统
  • 石景山做网站seo搜索优化是什么呢
  • vs做网站潍坊seo网络推广
  • 做网站竟然不知道cms重庆seo点击工具
  • 定制手机网站建设seo广告投放是什么意思
  • 四平网站建设合肥百度快速排名优化
  • 做得好的网站关键词排名查询网站
  • 工作女郎老板亲自测试新产品深圳网络优化公司
  • 做网站干什么用广东队对阵广州队
  • 凡科网上传网站seo自然优化排名
  • 公众号 接入wordpress优化关键词排名
  • java后端工程师什么是seo站内优化
  • 丰宁建设局网站seo数据分析
  • 哈尔滨网站制作建设网络营销类型
  • 网站建设最贵服务商如何制作一个宣传网页