How to translate the CC ++ program into Delphi (7)

zhaozj2021-02-17  49

Here Is A Real-World Example From The Winnt.h, Which is Not Possible To Translate To a Native Enumerated Type:

//

// Start Type

//

#define service_boot_start 0x00000000

#define service_system_start 0x00000001

#define service_AUTO_START 0X00000002

#define service_demand_start 0x00000003

#define service_disabled 0x00000004

//

//

//

Typedef enum _cm_service_load_type {

Bootload = service_boot_start,

SystemLoad = service_system_start,

AutoLoad = service_auto_start,

DemandLoad = service_demand_start,

Disableload = service_disabled

Service_load_type;

THE ORDINAL VALUES OF THE ITEMS in The Enumeration Service_Load_type Depend On The Constants Declared Above It. This is not Possible in Delphi. The Only Way to Translate It Is:

//

// Start Type

//

Const

Service_boot_start = $ 00000000;

Service_system_start = $ 00000001;

Service_auto_start = $ 00000002;

Service_demand_start = $ 00000003;

Service_disabled = 00000004;

//

//

//

Const

Bootload = service_boot_start;

SystemLoad = service_system_start;

AutoLoad = Service_Auto_Start;

Demandload = service_demand_start;

Disableload = service_disabled;

Type

TSERVICELOADTYPE = DWORD;

Back to Contents

转载请注明原文地址:https://www.9cbs.com/read-30423.html

New Post(0)