动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Delphi教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Delphi教程 ]的信息

本月文章推荐
.Delphi+汇编例子2.
.2个不错的通配符比较函数.
.控制Windows分辨率.
.关于Delphi中预编译指令的使用方.
.通用查询组件设计(续三).
.IntToBin(2-16进制转换函数).
.玩转Windows桌面图标.
.纸牌控件的编写(上).
.在Delphi7中调试COM+.
.工人线程中关闭窗体的实现.
.如何在注册表中注册BDE.
.如何得到本机的ip地址!.
.TreeView的使用.
.关于Windows2000透明窗体的制作.
.一个新算法的表达式求值的函数.
.建立自己的csdn知识管理库(1).
.在delphi中如何限制鼠标的移动区.
.DesignPattern之FactoryMethod.
.delphi一句话帮助.
.如何在程序中使用自己的库单元.

如何将C/C++程序转译成Delphi(六)

发表日期:2006-2-4 |


3.4. Strings

In C, as in Delphi, a string is an array of char types. Often, a string declaration is used in combination with a constant declaration specifying the maximum string length, as the following example shows:

#define RAS_MaxEntryName 256#define RASENTRYNAMEA struct tagRASENTRYNAMEARASENTRYNAMEA{  DWORD dwSize;  CHAR szEntryName[ RAS_MaxEntryName + 1 ];};

The first line declares a constant RAS_MaxEntryName with the value 256 specifying the maximum length of the string. The lines after it declare a struct (record) which contains a null-terminated string:

CHAR szEntryName[ RAS_MaxEntryName + 1 ];

The Delphi translation:

szEntryName : Array [0..RAS_MaxEntryName] of Char;

Why not Array [0..RAS_MaxEntryName+1] of Char? Recall that a C array starts with 0 and the declaration specifies the number of elements. Thus, Array [0..RAS_MaxEntryName+1] in Delphi is equivalent to [RAS_MaxEntryName+2] in C.


Back to contents

3.5. Enumerations - Two Methods

Enumerated types can be translated in two ways.

Method 1:

typedef enum _FINDEX_INFO_LEVELS {FindExInfoStandard,FindExInfoMaxInfoLevel} FINDEX_INFO_LEVELS;

This part of a C-header file translates easily to Delphi:

Type  TFindExInfoLevels = (FindExInfoStandard,                        FindExInfoMaxInfoLevel);

The ordinal Value of the item FindExInfoStandard is 0. In Delphi each enumeration starts with 0.

Method 2:

The following C-declaration is more problematic:

typedef enum _ACL_INFORMATION_CLASS {AclRevisionInformation = 1,AclSizeInformation} ACL_INFORMATION_CLASS

The "= 1" in the declaration forces C to start with the ordinal value 1. This is not possible in Delphi.

There are two ways to solve the problem.

Solution a): Declare the enumeration as

TACLInformationClass = (_Fill0,                         AclRevisionInformation,                         AclSizeInformation);

Solution b): Translate the enumeration as

CONST  AclRevisionInformation = 1;  AclSizeInformation = 2;TYPE  TACLInformationClass = DWord;

That's no problem for this example. But in C it's possible to specify the ordinal value of each item of the enumeration, for example:

Typedef enum _ENUMEXAMPLE {   Item1 = 5,  Item2 = 10,} ENUMEXAMPLE;

Using enumeration in Delphi the declaration would have to be done like this:

TEnumExample = (_Fill0,                 _Fill1,                 _Fill2,                 _Fill3,                 _Fill4,                 Item1,                 _Fill6,                 _Fill7,                 _Fill8,                 _Fill9,                 Item2);

This is hard to read and clumsy to maintain.

This works better:

CONST  Item1 = 5;  Item2 = 10;TYPE  TEnumExample = DWord;


Back to contents

上一篇:如何将C/C++程序转译成Delphi(五) 人气:4320
下一篇:如何将C/C++程序转译成Delphi(七) 人气:4135
浏览全部Delphi的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-10-14 25175学生成绩管理系统 v2.88
2008-10-14 冰雪CMS v2.0 bulid 081013
2008-10-14 Modoer多功能点评系统 v1.1 Beta
2008-10-14 乐风CMS乐风影视版 v2008.10.13
2008-10-14 FeitecCMS 40T免费资源网整站源码
2008-10-14 Asoft签到管理系统 v3.0 Pack2
2008-10-14 金博人才招聘求职网黄金版 v4.2
2008-10-14 游戏推广无限制版本
2008-10-14 AmEav WebSite 业网站管理系统 英
2008-10-11 联系人分组工具 v1.1 中文破解版
2008-10-11 FaceMelter变脸 v2.0 汉化破解版
2008-10-11 PathTracker道路跟踪仪 v1.2 破解
2008-10-11 Rooms手机聊天室 v0.6.7 破解版
2008-10-11 RemoteDesktop远程桌面 v1.0 破解
2008-10-11 ProRemote远程调音台 v1.0.1 破解
2008-10-11 PicShare照片共享 v1.0.0 破解版
2008-10-11 Photogene照片编辑器 v1.5 汉化破
2008-10-11 WriteRoom共享文档 v1.0 破解版
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | js/vbs加密 | md5加密 | 进制转换 | UTF-8 转换工具 | Html转换js | Html转换asp | Html转换php | Html转换perl
实用工具:汉字翻译拼音 | 拼音字典 | 符号对照表 | 个税计算 | 实时汇率查询换算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 | 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵
SEO対策 中国語教室 ホームページ作成