CreateProcess in NT4

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

LVL 2
mvz121697Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mriderCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mvz121697Author Commented:
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
mriderCommented:
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
mvz121697Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.