CreateProcess and local characters

Started by
10 comments, last by TheTroll 17 years, 11 months ago
Hi, I'm using CreateProcess to launch an executable but I noticed that if the executable is at my desktop the CreateProcess fails giving this last error: 267 The directory name is invalid. ERROR_DIRECTORY The problem seems to be that "Desktop" is spelled "Työpöytä" in finnish and I'm setting that as working directory (third last argument, lpCurrentDirectory) and thefore it fails. What should I do to make the CreateProcess handle the path correctly? Could it also be that it wants a DOS path? Thank you.
Jesus loves you!
Advertisement
Well I am going to assume that you have access to .net. My example is going to be in C# so you can go from there. I would suggest you use the Enviroment Class to get the properly qualified desktoppath.

desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

I hope this helps or gets you on the right path.

theTroll
Thanks for the reply the troll but I forgot to mention that I'm coding in C++ and no .net is available.
Jesus loves you!
Do you have access to MFC?

theTroll
Quote:Original post by TheTroll
Do you have access to MFC?

theTroll


No MFC either, just plain windows API.
Jesus loves you!
What OS are we talking about? Just to make sure I get the right API.

Once I have that give a few minutes and I should have something for you.

theTroll
Windows. I personally have XP but I want to support windows starting from at least 98 :)
Jesus loves you!
I did some looking around and this should have what you need.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima01/html/ima0187.asp

It should work all the way back to win98. I hope that helps, if you need any help with it let me know.

theTroll
Use CreateProcessW() and pass it a unicode string, like L"C:\Työpöytä\foo". I'm guessing you're compiling in multi-byte character set mode (not unicode), and the characters aren't going into the string properly.

EDIT: According to The MSDN you have to pass it a non-const buffer. So you'll need to copy that literal string into a buffer, then pass the buffer to CreateProcessW.
Evil Steve, the big problem with doing it that way is that the "desktop" folder in differnt OS version are in diffrent locations. That would only work on one OS. You have to make sure that you get the "desktop" folder for each OS version.

theTroll

This topic is closed to new replies.

Advertisement