Does ShellExecuteEx() be the same as execute command in Windows console?

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.



1
2
3
4
5
6
7
8
9
10
11
	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);



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
Please use an UNICODE build (from your test code i assume you did use an ANSI build).

If you double-click that file it is opened, right ? If it works in explorer, then must work with ShellExecuteExW()


Last edited on
Topic archived. No new replies allowed.