Solved

Path problem running a child DOS process under NT

Posted on 1998-12-02
7
368 Views
Last Modified: 2013-12-03
I have a problem when using CreateProcess to start a 16 bit DOS program in my MFC app. I want to run the child file viewer app when the user views one of my data files.
I am calling CreateProcess with lpCommandLine set to the full path of the DOS application plus just the name of the data file, and have tried both passing the data file's directory in as the lpCurrentDirectory parameter, and alternatively, using ::SetCurrentDirectory to set the working dir. Neither method seems to work, with the standard error value returning "file not found".

Note that I want the application to run on both Win9x and NT. Passing the current directory into CreateProcess seems to work well on Win95, but neither method works on NT.

I also want to include spaces in my path if possible :)
0
Comment
Question by:jjoz
7 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1416633
I guess, that dos program is loaded but it can't find the file, cause the filename is passed in long file name convention.
Try using GetShortPathName to convert the data file path to short name convention.

Regards, Madshi.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1416634
I think Madshi is right, though i'm stunned to rear that NT doesn't do the conversion itself when calling 'CreateProcess()'...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1416635
Hi Jürgen,

win95 doesn't do the conversion. I didn't test it with winNT, but I guess it's the same...   :-(

Regards... Madshi.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:jjoz
ID: 1416636
The problem seems to be related to the length of the path in which the data file is stored. It is about 5 directories deeps, which makes the path quite long.

So far I have found the best method is to get the 'short' version of the data file, and just pass it and thein via the lpCommandLine, ie the lpCommand eventually equals

c:\nms\bin\replay.exe c:\nms\projec~1.prj\melbou~1.prj\testmt~1.MT1\981201.dta\15'36'33.log

This works well, until the length of this command exceeds 142 chars!? The CreateProcess then fails returning "The parameter is incorrect". I recall reading something about using fully qualified paths (ie "\\servername\sharename\path") with NT to overcome path limitations, but I can't seems to relocate it now.

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1416637
This text is from the CreateFile documentation. I don't know, but I guess, you can use the same syntax with CreateProcess. Of course you then have to use CreateProcessW instead of CreateProcessA.

"Windows NT: You can use paths longer than MAX_PATH characters by calling the wide (W) version of CreateFile and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing. This lets you use paths that are nearly 32,000 Unicode characters long. You must use fully-qualified paths with this technique. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\tom_1\hotstuff\coolapps" is seen as "\\tom_1\hotstuff\coolapps"."

Regards, Madshi.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1416638
16 bit programs are limited to 127 characters in the command line.
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1416639
If you need to get around this, then you will need to do what some compilers do. Create a temporary file in a short directory. The contents of the file contains anything you want. Pass the name of this temporary file to the 16 bit application, but with a special character preceding the name. Then in the 16-bit application check the command line argument to see if it contains this special character. If it does, then get the real parameter from the file. Otherwise, process the command line argument normally.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now