今天突然碰到一个来自HUAWEI的“变态”需求,一个自解压小工具,同事是用NSIS做的,就释放了几个文件,然后弹一个对话框提示修复完成,但是HUAWEI要求该对话框不论是在中文操作系统还是英文操作系统上都要显示为英文。同事开始问我NSIS如何设置语言,后来看了下,NSIS的语言设置是处理其安装向导页面的显示语言的,而现在要求的是用MsgBox 弹窗提示文字全部为英文,于是感觉到,::MessageBox应该有高级点的用法,可以设置显示语言的,
查阅MSDN,发现
int WINAPI MessageBox(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType
);
这里只有四个参数,没有设置语言选项的参数,于是看了下跟这个相关的API
See also
居然有个带Ex的APIint WINAPI MessageBoxEx(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType,
_In_ WORD wLanguageId
);
要的正是这个,于是接着看wLanguageId相关的
To specify a language other than the current language, use the MAKELANGID macro to create this parameter. For more information, see MAKELANGID.
WORD MAKELANGID( USHORT usPrimaryLanguage, USHORT usSubLanguage );
0x0004 | Chinese (zh) | 0x04 | LANG_CHINESE_SIMPLIFIED | Simplified (Hans) | 0x02 | SUBLANG_CHINESE_SIMPLIFIED |
0x7C04 | Chinese (zh) | LANG_CHINESE_TRADITIONAL | Traditional (Hant) | 0x01 | SUBLANG_CHINESE_TRADITIONAL | |
0x0483 | Corsican (co) | 0x83 | LANG_CORSICAN | France (FR) | 0x01 | SUBLANG_CORSICAN_FRANCE |
0x001A | Croatian (hr); see note 2 | 0x1A | LANG_CROATIAN | Neutral | ||
0x101A | Croatian (hr) | 0x1a | LANG_CROATIAN | Bosnia and Herzegovina, Latin (BA) | 0x04 | SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN |
0x041A | Croatia (HR) | 0x01 | SUBLANG_CROATIAN_CROATIA | |||
0x0405 | Czech (cs) | 0x05 | LANG_CZECH | Czech Republic (CZ) | 0x01 | SUBLANG_CZECH_CZECH_REPUBLIC |
0x0406 | Danish (da) | 0x06 | LANG_DANISH | Denmark (DK) | 0x01 | SUBLANG_DANISH_DENMARK |
0x048C | Dari (prs) | 0x8C | LANG_DARI | Afghanistan (AF) | 0x01 | SUBLANG_DARI_AFGHANISTAN |
0x0465 | Divehi (dv) | 0x65 | LANG_DIVEHI | Maldives (MV) | 0x01 | SUBLANG_DIVEHI_MALDIVES |
0x0813 | Dutch (nl) | 0x13 | LANG_DUTCH | Belgium (BE) | 0x02 | SUBLANG_DUTCH_BELGIAN |
0x0413 | Netherlands (NL) | 0x01 | SUBLANG_DUTCH | |||
0x0C09 | English (en) | 0x09 | LANG_ENGLISH | Australia (AU) | 0x03 | SUBLANG_ENGLISH_AUS |
0x2809 | Belize (BZ) | 0x0A | SUBLANG_ENGLISH_BELIZE | |||
0x1009 | Canada (CA) | 0x04 | SUBLANG_ENGLISH_CAN | |||
0x2409 | Caribbean (029) | 0x09 | SUBLANG_ENGLISH_CARIBBEAN | |||
0x4009 | India (IN) | 0x10 | SUBLANG_ENGLISH_INDIA | |||
0x1809 | Ireland (IE);see note 3 | 0x06 | SUBLANG_ENGLISH_EIRE | |||
0x1809 | Ireland (IE);see note 3 | 0x06 | SUBLANG_ENGLISH_IRELAND | |||
0x2009 | Jamaica (JM) | 0x08 | SUBLANG_ENGLISH_JAMAICA | |||
0x4409 | Malaysia (MY) | 0x11 | SUBLANG_ENGLISH_MALAYSIA | |||
0x1409 | New Zealand (NZ) | 0x05 | SUBLANG_ENGLISH_NZ | |||
0x3409 | Philippines (PH) | 0x0D | SUBLANG_ENGLISH_PHILIPPINES | |||
0x4809 | Singapore (SG) | 0x12 | SUBLANG_ENGLISH_SINGAPORE | |||
0x1c09 | South Africa (ZA) | 0x07 | SUBLANG_ENGLISH_SOUTH_AFRICA | |||
0x2C09 | Trinidad and Tobago (TT) | 0x0B | SUBLANG_ENGLISH_TRINIDAD | |||
0x0809 | United Kingdom (GB) | 0x02 | SUBLANG_ENGLISH_UK | |||
0x0409 | United States (US) | 0x01 | SUBLANG_ENGLISH |
::MessageBoxEx(NULL, NULL, NULL, NULL, MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH));
管用,“确定”显示为OK,要的就是这个效果
兴奋中,本能的想法就是写个NSIS的插件,调用下这个带EX的API,
后来上了个厕所回来发现自己刚才傻了,直接在NSIS调用这个API就行了嘛