C 调用windowsAPI入门.doc

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C 调用windowsAPI入门.doc

使用C#调用wind?ows API入门(一) C# 调用 DLL 导出 其实我们的议?题应该叫做C?#如何直接调用?非托管代码,通常有2种方?法: 1.? DLL 导出的函数。 2.? COM 对象上的接口?方法 我主要讨论从?dll中导出? 1.使用 C# 关键字 static? 和 extern? 声明方法。 2.将 DllImp?ort 属性附加到该?方法。DllImp?ort 属性允许您指?定包含该方法?的 DLL 的名称。 3.如果需要,为方法的参数?和返回值指定?自定义封送处?理信息,这将重写 .NET Framew?ork 的默认封送处?理。 好,我们开始 1.首先我们查询?MSDN找到?GetSho?rtPath?Name的定? The GetSho?rtPath?Name functi?on retrie?ves the short path form of the specif?ied path. DWORD GetSho?rtPath?Name( LPCTST?R lpszLo?ngPath?, LPTSTR? lpszSh?ortPat?h, DWORD cchBuf?fer ); 2.查找对照表进?行数据类型的?转换(出处:http://msdn.micros?/msdnma?g/issues?/03/07/NET/defaul?t.aspx?fig=true )Data Types Win32 Types Specif?icatio?n CLR Type char, INT8, SBYTE, CHARa€? 8-bit signed? intege?r System?.SByte short, short int, INT16, SHORT 16-bit signed? intege?r System?.Int16 int, long, long int, INT32, LONG32?, BOOLa€?, INT 32-bit signed? intege?r System?.Int32 __int6?4, INT64, LONGLO?NG 64-bit signed? intege?r System?.Int64 unsign?ed char, UINT8, UCHARa?€?, BYTE 8-bit unsign?ed intege?r System?.Byte unsign?ed short, UINT16?, USHORT?, WORD, ATOM, WCHARa?€?, __wcha?r_t 16-bit unsign?ed intege?r System?.UInt16? unsign?ed, unsign?ed int, UINT32?, ULONG3?2, DWORD3?2, ULONG, DWORD, UINT 32-bit unsign?ed intege?r System?.UInt32? unsign?ed __int6?4, UINT64?, DWORDL?ONG, ULONGL?ONG 64-bit unsign?ed intege?r System?.UInt64? float, FLOAT Single?-precis?ion floati?ng point System?.Single? double?, long double?, DOUBLE? Double?-precis?ion floati?ng point System?.Double? a€?In Win32 this type is an intege?r with a specia?lly assign?ed meanin?g; in contra?st, the CLR provid?es a specif?ic type devote?d to this meanin?g. 3.调用GetS?hortPa?thName?这个API,简单的写法如?下(编译通过的话?), using System?; using System?.Runtim?e.Intero?pServi?ces; public? class MSSQL_?Server?Handle?r { [DllImp?ort(kernel?32.dll)] public? static? extern? int GetSho?rtPath?Name ( string? path, String?Builde?r shortP?ath, int short

文档评论(0)

cai + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档