Solved

Base Priority

Posted on 2003-11-08
6
306 Views
Last Modified: 2013-11-20
Hi

How do I change my app's default Base Priority from the default 8 to a higher value.
I done the following but it had no effect

  HANDLE hProc = GetCurrentThread();
  SetThreadPriority(THREAD_PRIORITY_HIGHEST);


0
Comment
Question by:Dj_Fx8
  • 3
  • 3
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9707575
SetPriorityClass(GetCurrentProcess(), ...);

All threads in the process get this priority. SetThreadPriority changes relative priority from the value set by SetPriorityClass.
0
 

Author Comment

by:Dj_Fx8
ID: 9742613
Hi Alex
Sorry for the delay I thought I had posted this a few days ago. I tried what you said but it had no effect I put the code in CMyApp::InitInstance, should it be somewhere else
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9745636
Yes, it should be in InitInstance. Please show your code, this should work.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Dj_Fx8
ID: 9758496
Hi Alex
Here the whole InitInstance

// CDjMM8App initialization

BOOL CDjMM8App::InitInstance()
{
      AfxEnableControlContainer();

      // Standard initialization
      // If you are not using these features and wish to reduce the size
      //  of your final executable, you should remove from the following
      //  the specific initialization routines you do not need.
/*      if(!AfxOleInit())
      {
            AfxMessageBox(_T("Ole Initialization failed"));
            return FALSE;
      }*/

      AfxGetModuleState()->m_dwVersion = 0x0601;

#ifdef _AFXDLL
      Enable3dControls();                  // Call this when using MFC in a shared DLL
#else
      Enable3dControlsStatic();      // Call this when linking to MFC statically
#endif

//      HANDLE hProc = GetCurrentThread();
      
///******H E R E   I S    Y O U R    C O D E
      SetPriorityClass(GetCurrentProcess(),16);

      // Set Registry Key
      SetRegistryKey(_T("KaS Software"));

      LoadStdProfileSettings();  // Load standard INI file options (including MRU)

      //** create the font I want to use throught the app
      m_ghFontTahoma90 = new CFont;
      VERIFY(m_ghFontTahoma90->CreatePointFont(90, _T("Tahoma")));

      //** Create the coloured brushes
      g_pbrWheat = new CBrush;
      g_pbrWheat->CreateSolidBrush(RGB(255,209,204));
      g_pbrTomatoe = new CBrush;
      g_pbrTomatoe->CreateSolidBrush(RGB(255,99,71));
      g_pbrPage = new CBrush;
      g_pbrPage->CreateSolidBrush(RGB(255,228,210));
      g_pbrBlack = new CBrush;
      g_pbrBlack->CreateSolidBrush(RGB(0,0,0));
      g_pbrRed = new CBrush;
      g_pbrRed->CreateSolidBrush(RGB(255,0,0));
      g_pbrGreen = new CBrush;
      g_pbrGreen->CreateSolidBrush(RGB(0,255,0));
      g_pbrYellow = new CBrush;
      g_pbrYellow->CreateSolidBrush(RGB(250,240,30));


      // Register the application's document templates.  Document templates
      //  serve as the connection between documents, frame windows and views.
      CSingleDocTemplate* pDocTemplate;
      pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CDjMM8Doc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
      RUNTIME_CLASS(CDjMM8View));
      AddDocTemplate(pDocTemplate);

      // Parse command line for standard shell commands, DDE, file open
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

      // The one and only window has been initialized, so show and update it.
      m_pMainWnd->ShowWindow(SW_SHOW);
      m_pMainWnd->UpdateWindow();


      //Initalise BASS
      if (!BASS_Init(1,44100,0,0,NULL)){
            CString szTemp;
            szTemp.Format("%d",BASS_ErrorGetCode());
            AfxMessageBox("The Audio Engine could not be initialised.\nIf the problem persists restart the computer\nError Code:" + szTemp + "\nBas Init", MB_ICONSTOP | MB_OK);
            AfxGetMainWnd()->PostMessage(WM_CLOSE);
      }
      BASS_Start();


      return TRUE;
}
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9758563
You can use the following constants with SetPriorityClass:

ABOVE_NORMAL_PRIORITY_CLASS       0x00008000
BELOW_NORMAL_PRIORITY_CLASS       0x00004000
HIGH_PRIORITY_CLASS                         0x00000080
IDLE_PRIORITY_CLASS                          0x00000040
REALTIME_PRIORITY_CLASS                 0x00000100

Read their description in MSDN topic SetPriorityClass and select one of them. Don't use hard-coded values.
You can check this code in the Task Manager. Right-click the process and select Set Priority. Current process priority is checked.
0
 

Author Comment

by:Dj_Fx8
ID: 9759953
Hi Alex
That got it sorted many thanks

Steven
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 94
method notes when mouse over in eclipse 5 68
lucky13 challenge 11 112
twoTwo  challenge 35 86
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now