Solved

CreateProcess in NT4

Posted on 1998-04-15
4
259 Views
Last Modified: 2010-04-06
I am building a new menu-program with the user-interface like the Windows NT4/95 explorer.
(With taskbar, Startmenu, Programs etc..)

When starting DOS-based app's using CreateProcess,
i want to control the memory-settings, like environment space, expanded memory, etc.
(the stuff under right-clicking an icon on the desktop,
property's, memory).

Where does NT save those settings ?
How can i force these settings with the createprocess
api-function ?

Greetings,
MvZ

0
Comment
Question by:mvz121697
[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
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
mrider earned 200 total points
ID: 1361527
all settings for dos programm placed into programname.pif, or, if this file doesn't exists, in
%SystemRoot%\_default.pif
and there are 2 files setting dos-environment for dos-emulator:
%SystemRoot%\SYSTEM32\CONFIG.NT,
%SystemRoot%\SYSTEM32\AUTOEXEC.NT
you need to edit pif-file manually(or from your programm) to set up needed propertys
0
 
LVL 2

Author Comment

by:mvz121697
ID: 1361528
if i want to start a dos-batch file (which itself starts a dos-exe file)
how do i make sure there is:

- 2048 ytes environment space
- min. 4Mb Expanded memory
- Full-screen application

How do i create the needed pif-file programaticly ?
0
 
LVL 1

Expert Comment

by:mrider
ID: 1361529
try to look at this routines:
  Function Exec(Path,Params,WorkPath:string; Wait:Boolean; Runmode:integer):boolean;
  {Path       Full path to the executable
   Params     Parameters
   WorkPath   Default directory, '' if same path as executable
   Wait       TRUE if execution of current program waits until new program finishes
   RUNMODE    How the application is executed (0 for default SHOWNORMAL):

      Value                  Meaning
      SW_HIDE                Hides the window and activates another window.
      SW_MAXIMIZE            Maximizes the specified window.
      SW_MINIMIZE            Minimizes the specified window and activates the
                             next top-level window in the Z order.
      SW_RESTORE             Activates and displays the window. If the window
                             is minimized or maximized, Windows restores it to
                             its original size and position. An application
                             should specify this flag when restoring a minimized
                             window.
      SW_SHOW                Activates the window and displays it in its current
                             size and position.
      SW_SHOWDEFAULT         Sets the show state based on the SW_ flag specified
                             in the STARTUPINFO structure passed to the CreateProcess
                             function by the program that started the application. An
                             application should call ShowWindow with this flag to set
                             the initial show state of its main window.
      SW_SHOWMAXIMIZED       Activates the window and displays it as a maximized window.
      SW_SHOWMINIMIZED       Activates the window and displays it as a minimized window.
      SW_SHOWMINNOACTIVE     Displays the window as a minimized window. The active
                             window remains active.
      SW_SHOWNA              Displays the window in its current state. The active
                             window remains active.
      SW_SHOWNOACTIVATE      Displays a window in its most recent size and position.
                             The active window remains active.
      SW_SHOWNORMAL          Activates and displays a window. If the window is minimized
                             or maximized, Windows restores it to its original size and
                             position. An application should specify this flag when
                             displaying the window for the first time.}

  var name:string;
      handle:integer;
      startUpInfo : TStartupInfo;
      processInfo       : TProcessInformation;
      exeCmd : string;
    begin
      if Runmode=0 then Runmode:=SW_SHOWNORMAL;
      if WorkPath='' then WorkPath:=extractfilepath(path);

      if wait
        then begin  // wait for the process to end...
               // Check to make{ If the execution file does not exist, then try
               // adding the path, if that fails then you're stuffed }
               if not FileExists(path) then begin
                  result := false;
                  exit;
               end;

               // Concat in the parameters
               exeCmd := path + ' ' + params;

               // Initialise the StartUpInfo record, which handles the creation of

               // a new main window for a process
               FillChar(startUpInfo, SizeOf(startUpInfo), Chr(0));
                    StartUpInfo.cb := SizeOf( StartUpInfo );
                    StartUpInfo.dwFlags     := STARTF_USESHOWWINDOW;
                    StartUpInfo.wShowWindow := runmode;

               // Spawn the process out.
                    if not CreateProcess(


                        nil, PChar(exeCmd), nil, nil, false,
                        CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
                        PChar(ExtractFilePath(path)), startUpInfo, processInfo
                      ) then begin
                  result := false;
               end;

               // Wait for ze old process to finish.
               WaitForSingleObject(processInfo.hProcess, INFINITE);
             end
        else begin
               handle:=ShellExecute(Application.Handle,'open',pchar(path),pchar(params),
                                    pchar(WorkPath),RunMode);
             end;
    end;


  Function ExecDOS(Path,Params,WorkPath,Title:String; Wait:Boolean; Minimized:Boolean):Boolean;
  {Just for DOS programs, creates a PIF file then executes it, deleting it afterward.
   Path       Full path to the executable
   Params     Parameters
   WorkPath   Default directory, '' if same path as executable
   Title      Title to display at top of window
   Wait       TRUE if execution of current program waits until new program finishes
   Minimized  TRUE if program is to run minimized.}
  var f:file;
      pifpath:string;
      a:string;
      ierr:integer;
    begin
      if WorkPath='' then WorkPath:=extractfilepath(path);

      // this is a generic PIF image that we've hacked to pieces...settings:
      //   Idle sensitivity set lowest
      //   Default window
      //   Exit on terminate
      //   All memory resources used if needed
      //   Allow screen saver
      //   Not dynamic allocation
      a:=#0#120#84#69#83#84#68#79#126#49#32#32#32#32#32#32#32#32#32#32+
      #32#32#32#32#32#32#32#32#32#32#32#32#128#2#0#0#68#58#92#116#101+
      #115#116#100#111#115#112#114#111#103#114#97#109#116#104#105#110+
      #103#46#101#120#101#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#16#0#101#58#92#116#101#109#112+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#45#101#120+
      #32#100#58#92#116#101#115#116#32#100#58#92#42#46#42#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#1#0#255#25#80#0#0#7#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#77#73+
      #67#82#79#83#79#70#84#32#80#73#70#69#88#0#135#1#0#0#113#1#87#73+
      #78#68#79#87#83#32#51#56#54#32#51#46#48#0#5#2#157#1#104#0#128+
      #2#0#0#100#0#50#0#255#255#0#0#255#255#0#0#2#0#2#0#159#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#45#101#120#32#100#58#92#116#101+
      #115#116#32#100#58#92#42#46#42#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#87+
      #73#78#68#79#87#83#32#86#77#77#32#52#46#48#0#255#255#27#2#172+
      #1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#80#73#70+
      #77#71#82#46#68#76#76#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#2#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#129#0#0#0#0#0#0#0#0#0#0#0#1#0#0#0#5#0#25#0#3#0#200#0+
      #232#3#2#0#10#0#1#0#0#0#0#0#0#0#28#0#0#0#0#0#0#0#8#0#12#0#84#101+
      #114#109#105#110#97#108#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#76#117#99#105#100#97#32#67#111#110#115#111#108#101+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#3#0#0#0#80#0#25#0#128+
      #2#44#1#0#0#0#0#22#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
      #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#0;
      title:=spaces(title,30);
      move(title[1],a[$02+1],30);

      if length(path)>63 then path:=copy(path,1,63);
      path:=path+#0;
      move(path[1],a[$24+1],length(path));

      if length(params)>63 then params:=copy(params,1,63);
      params:=params+#0;
      move(params[1],a[$a5+1],length(params));
      move(params[1],a[$1c5+1],length(params));

      if length(workpath)>63 then workpath:=copy(workpath,1,63);
      workpath:=workpath+#0;
      move(workpath[1],a[$65+1],length(workpath));

      if minimized
        then a[$1af+1]:=#$12
        else a[$1af+1]:=#$2;

      result:=false; // default unsuccessful
      pifpath:=newfilename(temppath+'00000000.pif',false);
      assignfile(f,pifpath);
      rewrite(f,1);
      ierr:=ioresult;
      blockwrite(f,a[1],length(a),ierr);
      closefile(f);
      if ierr<>length(a) then exit;
      result:=exec(pifpath,'','',wait,0);
      application.processmessages;
      if not wait then delay(1000); // we must wait one second for Windows to read file
      deletefile(pifpath);
    end;


0
 
LVL 2

Author Comment

by:mvz121697
ID: 1361530
Nice piece of code !
I am thinking of reading the string (a) dynamicly out of a series of predefined pif-files.
Maybe you know how to stuff one or more of the folowing:
- Fullscreen Yes/No
- Idle-sensitivity
- protected yes/no

Greetings,
MvZ
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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 Month3 days, 14 hours left to enroll

630 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