Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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

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
_franz
Asked:
_franz
  • 2
1 Solution
 
kevinb062397Commented:
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
 
_franzAuthor Commented:
Works in general, but NOT for my special application
(a linker with some commandline options)
Sorry.
0
 
kevinb062397Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now