Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Path problem running a child DOS process under NT

Posted on 1998-12-02
7
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

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 accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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