Solved

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

Posted on 1997-07-14
3
218 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
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 186
Convert GUI app into console app for Win32 Env 5 125
Delphi: ForceDirectory plain function 7 49
Firemonkey android show image from resource ? 1 56
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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