Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Path problem running a child DOS process under NT

Posted on 1998-12-02
7
Medium Priority
?
385 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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 200 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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

581 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