SetPriorityClass
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: SetPriorityClass

  1. #1
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    13

    SetPriorityClass

    I am to call "SetpriorityClass (thread, ABOVE_NORMAL_PRIORITY_CLASS) and it returns with an error - invalid handle on the GetLastError(). THis same handle to the thread is used in an immediate statement pthread->SetThreadPriority and all is well.

    I thought maybe I didn't have the correct values to Query and Set this in the DACL but I have not figured out how to set that easily - it is quite messy and not simple examples.

    Anyway know why the SetPriorityClass does not work?If is is a permissions problem on the thread (which I create quite standardly with "afxBeginThread")?

    Thanks in advance.

    Sharon

  2. #2
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: SetPriorityClass

    Quote Originally Posted by MSDN
    BOOL SetPriorityClass(
    HANDLE hProcess,
    DWORD dwPriorityClass
    );
    First parameter should be a handle to a process, not a thread. Hope you'll fix it from here
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  3. #3
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    13

    Re: SetPriorityClass

    I am not quite sure what the handle to the process is - if all I have is the thread that I created and its handle? What is considered the process if not the thread?

    Sharon

  4. #4
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: SetPriorityClass

    Use GetCurrentProcess() to get a pseudo-handle of your process.
    Then, call SetPriorityClass() to set the priority class for the specified process. This value together with the priority value of each thread of the process determines each thread's base priority level.
    If later needed to change the priority of a single thread in your process, use SetThreadPriority().
    Still need help?

    Best regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  5. #5
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    13

    Re: SetPriorityClass

    Thanks alot - it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center