ShellExecuteEx()是否与Windows控制台中的execute命令相同? [英] Does ShellExecuteEx() be the same as execute command in Windows console?

查看:119
本文介绍了ShellExecuteEx()是否与Windows控制台中的execute命令相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作系统是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

推荐答案

原则上,您可以在控制台应用程序中输入和输出中文(使用Unicode的任何内容).我尝试过这个.控制台API具有用于设置某些Unicode UTF编码的选项.我没有使用C ++进行此操作,但我使用.NET以及本机代码也进行了此操作,据我所记得(Delphi),所以在进行一些搜索后,您可以找到在何处进行设置.这是一个信息源: Unicode输出到Windows控制台 [
—SA
In principle, you can input and output Chinese (anything using Unicode) in console application. I tried it. Console API has options to set up some Unicode UTF encodings. I did not do it with C++, but I did with .NET and, with native code, too, as much as I remember (Delphi), so after some search you can find where to set it up. Here is one source of information: Unicode Output to the Windows Console[^].

Starting "CMD.exe" is a problem. "CMD /U" allows to output Unicode but not input.

—SA


这篇关于ShellExecuteEx()是否与Windows控制台中的execute命令相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆