[DUG] NtSetInformationProcess

Ross Levis ross at stationplaylist.com
Thu Oct 6 23:13:02 NZDT 2016


I have found code in C++ but I'm not good with dynamically loading DLLs to
access a function pointer.  Can someone please help me translate this for
Delphi.

 

    [DllImport("ntdll.dll", SetLastError = true)]

    public static extern int NtSetInformationProcess(IntPtr processHandle,

       PROCESS_INFORMATION_CLASS processInformationClass, ref IntPtr
processInformation, uint processInformationLength);

 

 

    enum IOPriority : uint

    {

        VeryLow = 0,

        Low = 1,

        Normal = 2,

    }

 

    static int SetIOPriority(IntPtr hProcess, IOPriority newPrio)

    {

        IntPtr ioPrio = (IntPtr) newPrio;

        int lret= NtSetInformationProcess(hProcess,
PROCESS_INFORMATION_CLASS.ProcessIoPriority, ref ioPrio, 4);

        return lret;

    }

ProcessIOPriority is a constant with the value 21.

 

Many thanks,
Ross.

 

From: Ross Levis [mailto:ross at stationplaylist.com] 
Sent: Thursday, 6 October 2016 4:48 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: NtSetInformationProcess

 

Can anyone provide the definition for accessing this Windows function.  It
doesn't exist in Windows.pas in Delphi 7.  I guess it's in kernel32.dll.

 

There seems to be some issue with my app inheriting a "Low" I/O priority
after a recent Windows 10 update and causing lots of issues with my
customers.  I want to try to set it to Normal.

 

Note this is not a Process or Thread Priority.

 

Cheers,

Ross.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20161006/1812d1c1/attachment.html 


More information about the Delphi mailing list