?
Solved

Starting 16bit DOS programs (CreateProcess(...)

Posted on 1997-07-14
3
Medium Priority
?
221 Views
Last Modified: 2010-04-06
I want to create a 16-bit DOS process with following code:

  GetStartupInfo(StartupInfo);
  Res := CreateProcess(nil, PChar(DOSApp), nil, nil,
    FALSE, CREATE_SEPARATE_WOW_VDM, nil, PChar(OUTDIR),
    StartupInfo, ProcessInfo);
  if Res then ...

This works fine, but just once! When I try do start the process again,
I get an error 87 (which means ERROR_INAVLIDE_PARAMETER)
0
Comment
Question by:_franz
[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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
kevinb062397 earned 100 total points
ID: 1338825
I use this code for most of my stuff.  I has yet to fail.

Try this:

Function TForm1.CreateProcessSimple(sExecutableFilePath:String):String;
Var
   pi:TProcessInformation;
   si:TStartupInfo;
Begin
   FillMemory(@si, sizeof(si),0);
   si.cb := sizeof(si);
   CreateProcess(Nil,Pchar(sExecutableFilePath),Nil,Nil, False, CREATE_NEW_CONSOLE,Nil,Nil,si,pi);
   CloseHandle(pi.hProcess);
   CloseHandle(pi.hThread);
end;


Procedure TFrom1.Button1Click (Sender: TObject);
Begin;
CreateProcessSimple('c:\windows\command\chkdsk.exe');
end;


0
 

Author Comment

by:_franz
ID: 1338826
Works in general, but NOT for my special application
(a linker with some commandline options)
Sorry.
0
 
LVL 1

Expert Comment

by:kevinb062397
ID: 1338827
Is this closer to what you are looking for?
It does not have the abilities that createprocess has but it's good for dos programs.

____start code______________________________________
   winexec(pchar('c:\command.com /c c:\windows\command\xcopy.exe'),sw_show);
____End code________________________________________

Just some FYI on command.com.

C:\WINDOWS>command /?
Starts a new copy of the Windows Command Interpreter.

COMMAND [[drive:]path] [device] [/E:nnnnn] [/L:nnnn] [/U:nnn] [/P] [/MSG]
                       [/LOW] [/Y [/[C|K] command]]
  [drive:]path    Specifies the directory containing COMMAND.COM.
  device          Specifies the device to use for command input and output.
  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
                  (nnnnn should be between 256 and 32,768).
  /L:nnnn         Specifies internal buffers length (requires /P as well).
                  (nnnn should be between 128 and 1,024).
  /U:nnn          Specifies the input buffer length (requires /P as well).
                  (nnn should be between 128 and 255).
  /P              Makes the new Command Interpreter permanent (can't exit).
  /MSG            Stores all error messages in memory (requires /P as well).
  /LOW            Forces COMMAND to keep its resident data in low memory.
  /Y              Steps through the batch program specified by /C or /K.
  /C command      Executes the specified command and returns.
  /K command      Executes the specified command and continues running.

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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 …
Suggested Courses

719 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