Solved

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

Posted on 1997-07-14
3
212 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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
kevinb062397 earned 50 total points
Comment Utility
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
Comment Utility
Works in general, but NOT for my special application
(a linker with some commandline options)
Sorry.
0
 
LVL 1

Expert Comment

by:kevinb062397
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

13 Experts available now in Live!

Get 1:1 Help Now