InstallScript InstallShield 中的字符 ASCII 代码
我想阻止用户输入字符 >安装程序中密码字段之一为 ASCII 127。
我用谷歌搜索但没有找到任何直接的方法,目前我正在使用:
CHAR ch;
STRING ASCII;
NUMBER nASCII;
for nCount = 0 to StrLength(sPassword)
ch = sPassword[nCount];
sprintf(ASCII,"%d",ch);
StrToNum(nASCII,ASCII);
if ( nASCII > 127 )
MessageBox("Invalid Character in Password",INFORMATION);
endif;
endfor;
Is there any better way to get ASCII code from a string?
I want to keep user from entering character > ASCII 127 in one of the password field in installer.
I googled but didn't find any direct way for this, currently i'm using:
CHAR ch;
STRING ASCII;
NUMBER nASCII;
for nCount = 0 to StrLength(sPassword)
ch = sPassword[nCount];
sprintf(ASCII,"%d",ch);
StrToNum(nASCII,ASCII);
if ( nASCII > 127 )
MessageBox("Invalid Character in Password",INFORMATION);
endif;
endfor;
Is there any better way to get ASCII code from a string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我会避免与字符串之间的转换;只需直接将
sPassword[nCount]
与127
进行比较即可; InstallScript 存储宽字符(16 位数字)。作为替代方法,您可以尝试调用 WideCharToMultiByte< /a> 与 US-ASCII 代码页 (20127)。我对 InstallScript 的了解不是那么强,并且在没有编译器的情况下进行编码,因此您可能需要修复一两个错误,但粗略的想法如下:
First off, I would avoid the conversion to and from string; just compare
sPassword[nCount]
with127
directly; InstallScript stores wide chars (16-bit numbers).As an alternative approach, you might try calling WideCharToMultiByte with the US-ASCII code page (20127). I'm not that strong with InstallScript and am coding without the compiler, so you might have to fix an error or two, but here's the rough idea: