javascript和vbscript中没有结构体Struct,ePass的ActiveX对象中把各个参数都展开了,官方文档只给出了对应的代码,没有给出相应的数字,示例代码中却都是数字,其VC代码中有对应的定义,如下
ePass.CreateFile(IFlags, ulID, ulFileSize, ucFileType, ucReadAccess, ucWriteAccess, ucCryptAccess, ucGrantedAccess);
////
/// EPAS_FILEINFO structure definition
//
typedef struct tagFILEINFO
{
unsigned long ulID; //File ID.
unsigned long ulFlags; //Reserved.MUST be zero
unsigned long ulFileSize;
unsigned char ucFileType;
unsigned char ucReadAccess;
unsigned char ucWriteAccess;
unsigned char ucCryptAccess;
unsigned char ucReserved1[12];
unsigned char ucGrantedAccess;
unsigned char ucReserved2[15];
}EPAS_FILEINFO, *PEPAS_FILEINFO;
/////
//// FILEINFO.FileType
/// File type definition
//
#define EPAS_FILETYPE_UNUSED 0x00
#define EPAS_FILETYPE_DIR 0x01
#define EPAS_FILETYPE_DATA 0x02
#define EPAS_FILETYPE_KEY 0x04
#define EPAS_FILETYPE_UNKNOWN 0xFF
/////
//// FILEINFO.ReadAccess,FILEINFO.WriteAccess,FILEINFO.CryptAccess
/// File access types
//
#define EPAS_ACCESS_ANYONE 0x00
#define EPAS_ACCESS_USER 0x01
#define EPAS_ACCESS_OFFICER 0x02
#define EPAS_ACCESS_NONE 0x07
////
/// FILEINFO.GrantedAccess
//
#define EPAS_ACCESS_READ 0x01
#define EPAS_ACCESS_WRITE 0x02
#define EPAS_ACCESS_CRYPT 0x04
javascript也可以用这种方式将对象解释为结构:
var FileType = { EPAS_FILETYPE_UNUSED: 0, EPAS_FILETYPE_DIR: 1, EPAS_FILETYPE_DATA: 2, EPAS_FILETYPE_KEY: 4, EPAS_FILETYPE_UNKNOWN: 0xFF }; ///// //// FILEINFO.ReadAccess,FILEINFO.WriteAccess,FILEINFO.CryptAccess /// File access types // var FileAccess = { EPAS_ACCESS_ANYONE: 0x00, EPAS_ACCESS_USER: 0x01, EPAS_ACCESS_OFFICER: 0x02, EPAS_ACCESS_NONE: 0x07 } var GrantedAccess = { EPAS_ACCESS_READ: 0x01, EPAS_ACCESS_WRITE: 0x02, EPAS_ACCESS_CRYPT: 0x04 }这样调用:ePass.CreateFile(0, 1, 16, FileType.EPAS_FILETYPE_KEY, FileAccess.EPAS_ACCESS_ANYONE, FileAccess.EPAS_ACCESS_ANYONE, FileAccess.EPAS_ACCESS_ANYONE, FileAccess.EPAS_ACCESS_ANYONE);
ePass.CreateFile