Changing scheduling priority of a process at runtime

I had a requirement sometime back to make my process have a higher priority at runtime, so went hunting around for an API which does this and found one with an intuitive name, “SetPriorityClass”. So what is process priority? Process priority is the value which determines priority of a process when it’s being scheduled. If […]
Continue reading…

 

How to get name of owner of a process?

Here is a function that extracts the name of the owner of a process… [sourcecode language=’cpp’]bool ExtractProcessOwner( HANDLE hProcess_i,                           CString& csOwner_o ) {    // Get process token    HANDLE hProcessToken = NULL;    if ( !::OpenProcessToken( hProcess_i, TOKEN_READ, &hProcessToken ) || !hProcessToken )    {       return false;    }    // First get […]
Continue reading…

 

Function for enabling privileges for your application!

Here is the code that does this… [sourcecode language=’cpp’]// Set up access void SetUpAccess() {     HANDLE hProcToken = 0;     if( !OpenProcessToken( GetCurrentProcess(),                            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,                            &hProcToken ))     {         return;     }     // List of privileges, all of them, he he 😀     LPCTSTR lpctszPrivileges[] = { SE_CREATE_TOKEN_NAME,                                    […]
Continue reading…