Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:07:39+00:00 2026-05-28T18:07:39+00:00

How can I create and run a process from my program with the ability

  • 0

How can I create and run a process from my program with the ability to set the priority of the process?

This is what I have so far:

const
  LOW_PRIORITY            = IDLE_PRIORITY_CLASS;
  //BELOW_NORMAL_PRIORITY = ???
  NORMAL_PRIORITY         = NORMAL_PRIORITY_CLASS;
  //ABOVE_NORMAL_PRIROTY  = ???
  HIGH_PRIORITY           = HIGH_PRIORITY_CLASS;
  REALTIME_PRIORITY       = REALTIME_PRIORITY_CLASS;

procedure RunProcess(FileName: string; Priority: Integer);
var
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  Done: Boolean;
begin
  FillChar(StartInfo,SizeOf(TStartupInfo),#0);
  FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
  StartInfo.cb := SizeOf(TStartupInfo);
  try
    Done := CreateProcess(nil, PChar(FileName), nil, nil,False,
                          CREATE_NEW_PROCESS_GROUP + Priority,
                          nil, nil, StartInfo, ProcInfo);
    if not Done then
      MessageDlg('Could not run ' + FileName, mtError, [mbOk], 0);
  finally
    CloseHandle(ProcInfo.hProcess);
    CloseHandle(ProcInfo.hThread);
  end;
end;

The above code works in that I can set the priority of the executed process. But see the image below of the Windows Task Manager:

Screenshot of Task Manager

You can set more options such as Below Normal and Above Normal which is what I want to also be able to set. Looking through Windows.pas I see no such value.

How can I create and run my process with those extra parameters?

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:07:40+00:00Added an answer on May 28, 2026 at 6:07 pm

    Those two flags are not declared in the Windows.pas that ships with Delphi. You will have to declare these values for yourself. The values can be found in the MSDN documentation of SetPriorityClass.

    const
      BELOW_NORMAL_PRIORITY_CLASS = $00004000
      ABOVE_NORMAL_PRIORITY_CLASS = $00008000
    

    As an aside remember that CreateProcess modifies its second parameter, lpCommandLine, the parameter to which you pass PChar(FileName). So your code will fail if you call the function passing a string literal which lives in read-only memory. I would add the following line

    UniqueString(FileName);
    

    immediately before the call to CreateProcess. More information can be found here: Access Violation in function CreateProcess in Delphi 2009

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have .NET program that can't be run from Visual Studio for some reasons
I'm trying to create a small program to run on a centralized device. This
This question comes from here but can be a totally independent question. I have
I'm using process.Start to run Convert.exe. This program's purpose is to convert all files
I'm confused. I have program which I run as a non-administrator user. This program
Can not run following SQL from ant's sql task : BEGIN DBMS_AQADM.CREATE_QUEUE_TABLE( queue_table =>
What I need to do is create a web application that can run inside
I need to create an empty .mdb file, so that I can then run
In Flex, how do I create a CheckBox that can't be un-checked? I run
Here is the situation: I have to create a program that would input another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.