Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting the windows 2000 process priority
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00601173
Message ID:
00601982
Vues:
31
>>>>>Does anyone know how to set the priority of a process in windows 2000 programatically from VFP?
>>>>
>>>>Hi Eylon,
>>>>
>>>>Take a look at Message #527632 for some ideas.
>>>
>>>Hello Sergey - I did - thanks. Still - this is for a VFP 6 app and I need a way to get the windows handle from the form.
>>>
>>You can use FindWindow to get window handle. See API #12638.
>
>I wrote something like this:
>
>
>DECLARE INTEGER GetWindowThreadProcessId IN user32 INTEGER, INTEGER@
>DECLARE INTEGER FindWindow IN Win32API;
>STRING @lpClassName, ;
>STRING @lpWindowName
>declare integer OpenThread in kernel32 integer lnaccess, integer lninherit, integer inthreadID
>declare integer CloseHandle in kernel32 integer
>#DEFINE THREAD_BASE_PRIORITY_MIN -2
>#DEFINE THREAD_PRIORITY_HIGHEST 2
>#DEFINE THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
>#define THREAD_SET_INFORMATION 0x20
>DECLARE SHORT SetThreadPriority in kernel32 INTEGER hThread, INTEGER nPriority
>DECLARE SHORT GetThreadPriority in kernel32 INTEGER hThread
>lcApplicationTitle = _screen.caption
>lnHWnd = FindWindow(0, @lcApplicationTitle)
>local lnprocID, lnthreadID
>lnprocID = 1
>lnthread_ID = GetWindowThreadProcessId(lnHWnd, @lnprocID)
>local lnhthread
>lnhthread = OpenThread(THREAD_SET_INFORMATION,0,lnThread_ID)
>xx=getThreadPriority(lnhthread)
>yy=SetThreadPriority(lnhthread, THREAD_PRIORITY_HIGHEST)
>aa=getThreadPriority(lnhthread)
>=CloseHandle(lnhthread)
>
>
>Everything seems to work fine except that the priority remains unchanged - I checked xx and aa before and after, and yy gave 1, meaning success.
>
>Any Ideas???
>
>TIA, Eylon

Take a look at faq #7593. I think following quote applies to your code also: "Under NT and Win2K, the process issuing the SetPriorityClass call must have a process handle with the PROCESS_SET_INFORMATION access right, which may require calling AdjustTokenPrivileges, a non-trivial issue."

See mskb #Q251310 for how the process token security can be ajusted.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform