Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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