• Advertisement
Sign in to follow this  

CreateProcess and local characters

This topic is 4317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Thanks for the reply the troll but I forgot to mention that I'm coding in C++ and no .net is available.

Share this post


Link to post
Share on other sites
Quote:
Original post by TheTroll
Do you have access to MFC?

theTroll


No MFC either, just plain windows API.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Windows. I personally have XP but I want to support windows starting from at least 98 :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Hey got it working. First of thank you for all the help TheTroll, I apreciate it! Second there was nothing wrong in the working directory's path, it was just the application's own path which was wrong - because of the working path. Well you can put (say) that in a couple of ways, however this problem is solved.

Thanks again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement