AnsweredAssumed Answered

vrf AW: Privileges (was: CPU Usage)

Question asked by VRFuser on Dec 3, 2003
Now I know by experience why HIGH_PRIORITY_CLASS must be used with care )

Many thanks to Georg and Shawn for their examples - according to their own words, looks to me like they started programming API in the early 17th. century!

Thanks again,


-----Ursprngliche Nachricht-----
Von: []
Gesendet: Mittwoch, 3. Dezember 2003 17:44
Betreff: [vrf] Privileges (was: CPU Usage)


> Q: how do I get in VEE explicit 'hProcess' and 'hThread' and how to

You have to use
     hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId)
to get the process handle you need.
The dwDesiredAccess should be PROCESS_QUERY_INFORMATION OR PROCESS_SET_INFORMATION and bInheritHandle=False. dwProcessID is the ID of the process that you get when calling GetCurrentProcessId(). Don't forget to close the handle after usage!!! CloseHandle(hObject);

See attached example!

Use HIGH_PRIORITY_CLASS with care. If a thread runs at the highest priority level for extended periods, other threads in the system will not get processor time. If several threads are set at high priority at the same time, the threads lose their effectiveness. The high-priority class should be reserved for threads that must respond to time-critical events. If your application performs one task that requires the high-priority class while the rest of its tasks are normal priority, use SetPriorityClass to raise the priority class of the application temporarily; then reduce it after the time-critical task has been completed. The important point is that a high-priority thread should execute for a brief time, and only when it has time-critical work to perform.
You should almost never use REALTIME_PRIORITY_CLASS, because this interrupts system threads that manage mouse input, keyboard input, and background disk flushing. This class can be appropriate for applications that "talk" directly to hardware or that perform brief tasks that should have limited interruptions.

> '(int32)0' as shown in the example winmm.vee for 'hModule' will bring
> SystemErrorCode '6' ERROR_INVALID_HANDLE - reckon should provide something
> different.

Yes, very different see above

> Looks like using kernel32.dll separates the man from the boys.....

Thats logical: you grow old while learning to use the API

best regards,

G. Nied

Georg Nied  - Software-Development - Hansestr.7 - 51149 Cologne - Germany
Tel: +49 2203 9770915 - Fax: +49 2203 9770924 -

You are currently subscribed to vrf as:
To subscribe send a blank email to "".
To unsubscribe send a blank email to "".
To send messages to this mailing list,  email "". 
If you need help with the mailing list send a message to "".