Problem with ShellExecute

Hello.
That program should open files with cyrillic names.

#include "stdafx.h"
#include <windows.h>
#include <Shellapi.h>
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
.........
//"word" is string in cyrillic alphabet
//I convert "word" from string to char[100]
k=word.length();
for (int z=0; z<k; z++)
temp[z]=word.at(z);
temp[k]='\0';
ShellExecute(NULL, _T("open"), temp, _T(""), _T(""), SW_SHOW);

But this function doesn't work and GetLastError() shows error 2. But there is no any problems with latin alphabet. How I can solve that problem?
P.S. I use Multi-byte in project properties.
Thank you.
Error Code 2 simply means "File Not Found": http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx

ShellExecte: http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx
Is the target file name also in Cyrillic? If not then you may consider casting "word" into an integer array and making sure that it matches the integer cast of the target file name after it's all converted.

Your fourth argument should be NULL if you mean to open a document.

Your fifth arguement which should be the directory the target file appears in is blank. If you mean to use the current working directory you should change that to NULL.

You should test the return value to see what the error it is throwing is.
Last edited on
You should always use UNICODE and ShellExecuteW() if you want to avoid such problems, unless you want your app to run on windows 98 or lower.
Thanks for answers.
I solve the problem. It was in converting words, which I type in command line (OemToChar function). ShellExecute works correctly.
Topic archived. No new replies allowed.