HTML+JavaScript构建一个将C/C++定义的ANSI字符串转换为MASM32定义的DWUniCode字符串的工具

公文一键排版系统基本完成,准备继续完善SysInfo,增加用户帐户信息,其中涉及到Win32_Account结构,其C++定义如下:

[Dynamic, Provider("CIMWin32"), UUID("{8502C4CC-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT]
class Win32_UserAccount : Win32_Account
{
uint32 AccountType;
string Caption;
string Description;
boolean Disabled;
string Domain;
string FullName;
datetime InstallDate;
boolean LocalAccount;
boolean Lockout;
string Name;
boolean PasswordChangeable;
boolean PasswordExpires;
boolean PasswordRequired;
string SID;
uint8 SIDType;
string Status;
};

 由于WMI使用的是UniCode(WCHAR),所以我们在MASM32中要将以上成员属性AccountType、Caption……按DW UniCode(WCHAR)来定义,如下:

AccountType dw 'A','c','c','o','u','n','t','T','y','p','e', 0, 0
Caption dw 'C','a','p','t','i','o','n', 0, 0
Description dw 'D','e','s','c','r','i','p','t','i','o','n', 0, 0
Disabled dw 'D','i','s','a','b','l','e','d', 0, 0
Domain dw 'D','o','m','a','i','n', 0, 0
FullName dw 'F','u','l','l','N','a','m','e', 0, 0
InstallDate dw 'I','n','s','t','a','l','l','D','a','t','e', 0, 0
LocalAccount dw 'L','o','c','a','l','A','c','c','o','u','n','t', 0, 0
Lockout dw 'L','o','c','k','o','u','t', 0, 0
Name dw 'N','a','m','e', 0, 0
PasswordChangeable dw 'P','a','s','s','w','o','r','d','C','h','a','n','g','e','a','b','l','e', 0, 0
PasswordExpires dw 'P','a','s','s','w','o','r','d','E','x','p','i','r','e','s', 0, 0
PasswordRequired dw 'P','a','s','s','w','o','r','d','R','e','q','u','i','r','e','d', 0, 0
SID dw 'S','I','D', 0, 0
SIDType dw 'S','I','D','T','y','p','e', 0, 0
Status dw 'S','t','a','t','u','s', 0, 0

虽然MASM32 在QEDITOR 的 Conversions里提供了Text to DW UNICODE菜单项功能,但这个菜单项还不能实现自动从类中提出成员属性名称并转换为MASM32的DW UNICODE字符串的格式,所以我们还是先得手工将AccountType、Caption……提取出来。

成员少还行,成员多的话就太麻烦了。

于是用HTML+JavaScript写了一个简单的转换工具,运行效果如下:

HTML+JavaScript构建一个将C/C++定义的ANSI字符串转换为MASM32定义的DWUniCode字符串的工具_第1张图片

 

完整代码如下:



 
  
  
  
  
  
  ANSI String 2 MASM32 DW UniCode String
 
 

ANSI String 2 MASM32 DW UniCode String  

ANSI 字符串

MASM32 DW UniCode String

你可能感兴趣的:(MASM32,原创作品,JavaScript,html,javascript,数据结构,MASM32,Unicode,代码转换)