问题描述
我的操作系统是Windows XP英文,在我的计算机控制台中,我无法输入中文.如果我将汉字复制到控制台中,它将转换为问号.
因此,如果我运行"javaw.exe [中文参数]"(例如"javew.exe TestEnglish.doc"),则我的java main()中将获得"Test ??.doc".
现在,我正在使用ShellExecuteEx()在我的项目中执行命令.传递给ShellExecuteEx()的参数可能包含Unicode字符.
My OS is Windows XP English, in the console of my computer, I can not input Chinese. If i copy Chinese character into console, it will be converted to be question mark.
Therefore, if i run "javaw.exe [parameters with Chinese]" (e.g. "javew.exe Test中文.doc"), i will get "Test??.doc" in my java main().
Now, i''m using ShellExecuteEx() to execute a command in my project. The parameter passed into ShellExecuteEx() may contain unicode characters.
SHELLEXECUTEINFO shellExecuteInfo = {0};
shellExecuteInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shellExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shellExecuteInfo.hwnd = NULL;
shellExecuteInfo.lpVerb = _T("open");
shellExecuteInfo.lpFile = "javaw.exe";
shellExecuteInfo.lpParameters = (wchar_t*)pParamUTF16Str; //pParamUTF16Str includes string "Test中文.doc";
shellExecuteInfo.lpDirectory = NULL;
shellExecuteInfo.nShow = SW_HIDE;
shellExecuteInfo.hInstApp = NULL;
bool ret = ShellExecuteEx(&shellExecuteInfo);
我还将在我的java main()中获得"Test ??.doc",因此我猜想使用ShellExecuteEx()与在Windows控制台(C:\ Windows \ system32 \ cmd.exe)中运行命令相同.对吧?
顺便说一句,如果我在区域和语言选项中将非Unicode程序的语言更改为中文",那么我可以在控制台中输入中文,并且此代码效果很好.
谢谢,
Aidy
I also will get "Test??.doc" in my java main(), so i guess using ShellExecuteEx() is as same as running the command in Windows console (C:\Windows\system32\cmd.exe), is that right?
BTW, if i change the Language for non-Unicode programs to be "Chinese" in the regional and language options, then i can input Chinese in console and this code works well.
Thanks,
Aidy
推荐答案
这篇关于ShellExecuteEx()是否与Windows控制台中的execute命令相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!