Delphi¶àÏß³Ìѧϰ(8)£ºÓÅÏȼ¶
Ò»¸öÏ̵߳ÄÓÅÏȼ¶È¡¾öÓÚ´´½¨Ï̵߳Ľø³ÌµÄÓÅÏȼ¶£¨priority class£©ºÍÏ̱߳¾ÉíÏà¶ÔµÄÓÅÏȼ¶£¨relative priority£©¡£
1¡¢½ø³ÌÓÅÏȼ¶£º
²»Í¬²Ù×÷ϵͳ ÓÅÏȼ¶ÊýÄ¿²»Í¬¡£Windows2000ÒÔÉϵİ汾ÁбíÈçÏ£º
Idle£º£¨±êÖ¾£ºIDLE_PRIORITY_CLASS£¬ÖµÎª$40£©£»
Below Normal£º£¨±êÖ¾£ºBELOW_NORMAL_PRIORITY_CLASS£¬ÖµÎª$4000£©£»
Normal£º£¨±êÖ¾£ºNORMAL_PRIORITY_CLASS£¬ÖµÎª$20£©£»
Above Normal£º£¨±êÖ¾£ºABOVE_NORMAL_PRIORITY_CLASS£¬ÖµÎª$8000£©£»
High£º£¨±êÖ¾£ºHIGH_PRIORITY_CLASS£¬ÖµÎª$80£©£»
Realtime£º£¨±êÖ¾£ºREALTIME_PRIORITY_CLASS£¬ÖµÎª$100£©¡£
½ø³ÌµÄȱʡÓÅÏȼ¶ÎªNormal£¬¼¸ºõËùÓг¡ºÏ¶¼²»Ó¦½«ÓÅÏȼ¶ÉèΪRealtime¡£
´´½¨½ø³Ìʱ¸ø¶¨ÓÅÏȼ¶£¬Ö»ÒªÔÚCreateProcessÖУ¬½«ÓÅÏȼ¶±êÖ¾×ö“OR”²Ù×÷£¬ÌîÈëdwCreationFlags²ÎÊýÖС£
È¡µÃ»î¶¯½ø³ÌµÄÓÅÏȼ¶£º
function GetPriorityClass(hProcess:THandle):DWORD;stdcall;
ÉèÖû½ø³ÌµÄÓÅÏȼ¶£º
function SetPriorityClass(hProcess:THandle;dwPriorityClass:DWORD);BOOL;
£¨ÉÏÃæÁ½¸öº¯ÊýµÄhProcessÓÉGetCurrentProcessº¯Êý»ñµÃ£¬Õâ¸ö¾ä±ú²»ÓÃCloseHandle¹Ø±Õ£©
2¡¢Ïß³ÌÏà¶ÔÓÅÏȼ¶£º
Ïß³ÌÓÅÏȼ¶·Ö7À࣬ÈçÏ£º
tpIdle£º£¨³£Á¿£ºTHREAD_PRIORITY_IDLE£¬ÖµÎª-15£©£»
tpLowest£º£¨³£Á¿£ºTHREAD_PRIORITY_LOWEST£¬ÖµÎª-2£©£»
tpBelow Normal£º£¨³£Á¿£ºTHREAD_PRIORITY_BELOW_NORMAL£¬ÖµÎª-1£©£»
tpNormal£º£¨³£Á¿£ºTHREAD_PRIORITY_NORMAL£¬ÖµÎª0£©£»
tpAbove Normal£º£¨³£Á¿£ºTHREAD_PRIORITY_ABOVE_NORMAL£¬ÖµÎª1£©£»
tpHighest£º£¨³£Á¿£ºTHREAD_PRIORITY_HIGEST£¬ÖµÎª2£©£»
tpTimeCritical£º£¨³£Á¿£ºTHREAD_PRIORITY_TIME_CRITICAL£¬ÖµÎª15£©£»
¶ÔÓÚÏß³ÌÀàTThread£¬¸Ä±äÏß³ÌÓÅÏȼ¶·Ç³£·½±ã£¬Ö»Òª½«ÅÉÉúÀàµÄPriorityÊôÐÔÏàÓ¦ÉèÖþͺÃÁË¡£È磺MyThread.Priority:=tpHighest;
3¡¢Ïß³ÌÓÅÏȼ¶¼ÆË㣺
Èç¹ûÏß³ÌÓÅÏȼ¶ÎªtpIdle£¬ÎÞÂÛËüËù´¦µÄ½ø³ÌÓÅÏȼ¶ÊǶàÉÙ£¬Ïß³ÌÕûÌåÓÅÏȼ¶×ÜÊÇ1£¬µ«ÊÇ£¬µ±½ø³ÌÓÅÏȼ¶ÎªRealtimeʱ£¬ÄÇôÓëtpIdleÏà×éºÏ£¬Ïß³ÌÕûÌåÓÅÏȼ¶Îª16£»
Èç¹ûÏß³ÌÓÅÏȼ¶ÎªtpTimeCritical£¬ÎÞÂÛËüËù´¦µÄ½ø³ÌÓÅÏȼ¶Îª¶àÉÙ£¬ÕûÌåÓÅÏÈ×é¶¼ÊÇ15£¬µ«ÊÇ£¬µ±½ø³ÌÓÅÏȼ¶ÊÇRealtimeʱ£¬ÄÇÓëtpTim
Ïà¹ØÎĵµ£º
ÓÃDelphi ʵÏÖ´®¿ÚͨѶ£¬³£Óõļ¸ÖÖ·½·¨Îª£ºÊ¹ÓÿؼþÈçMSCOMMºÍSPCOMM£¬Ê¹ÓÃAPIº¯Êý»òÕßÔÚDelphi Öе÷ÓÃÆäËü´®¿ÚͨѶ³ÌÐò¡£ÀûÓÃAPI±àд´®¿ÚͨÐųÌÐò½ÏΪ¸´ÔÓ£¬ÐèÒªÕÆÎÕ´óÁ¿Í¨ÐÅ֪ʶ£¬ÆäÓŵãÊÇ¿ÉʵÏֵŦÄܸüÇ¿´ó£¬Ó¦ÓÃÃæ¸ü¹ã·º£¬¸üÊʺÏÓÚ±àд½ÏΪ¸´ÔÓ µÄµÍ²ã´ÎͨÐųÌÐò¡£Ïà±È½Ï¶øÑÔ£¬ÀûÓÃSPComm¿Ø¼þÔòÏà¶Ô½Ï¼òµ¥£¬¸Ã¿Ø¼þ¾ßÓ ......
DelphiÌṩµÄ×Ö·û´®º¯ÊýÀïÓÐÒ»¸öPosº¯Êý£¬ËüµÄ¶¨ÒåÊÇ£º
function Pos(Substr: string; S: string): Integer;
ËüµÄ×÷ÓÃÊÇÔÚ×Ö·û´®SÖвéÕÒ×Ö·û´®Substr£¬·µ»ØÖµÊÇSubstrÔÚSÖеÚÒ»´Î³öÏÖµÄλÖã¬Èç¹ûûÓÐÕÒµ½£¬·µ»ØÖµÎª0¡£
ʹÓÃposº¯ÊýÀ´²éÕÒ×Ö·ûµÚÒ»´Î³öÏÖµÄλÖÃ
var
str1:string;
i,j:integer;
begin
str1:='dsf465 ......
2010-02-22 17:08:46
Delphi°Ñ¶àÏß³ÌÏà¹ØµÄAPI·â×°ÔÚTThreadÕâ¸öÀàÖУ¬¿ÉÒÔ·½±ãʵÏÖ¶àÏß³ÌÔËÓá£Ê×ÏÈ¿´ÏÂTThreadµÄÉùÃ÷£º
TThread = class
private
FHandle: THandle;
FThreadID: THandle;
FCreateSuspended: Boolean;
FTerminated: Boolean;
FSuspended: Boolean;
FFreeOnTerminate: ......
ÔÚʹÓöàÏ̵߳Äʱºò£¬Èç¹û¶àÏ̶߳Ôij¸öÌØ¶¨µÄ¹«¹²Êý¾Ý»ò×ÊÔ´½øÐзÃÎÊ£¬ÐèÒª¶Ô¶àÏ߳̽øÐÐе÷²Ù×÷£¬½Ð×öÏß³Ìͬ²½¡£
ÀýÈ磺Èý¸öÏ̷ֱ߳ðÑ»·µØÏòListBoxÖÐдÈëÊý¾Ý¡£Ã»ÓнøÐÐͬ²½Ê±£¬Ð´ÈëµÄ˳ÐòÊDz»È·¶¨µÄ¡£
{Ö÷´°Ìå´úÂë}
unit Unit2;
interface
uses
Windows, Messages, SysUtils, V ......
ÐźÅÁ¿Êǽ¨Á¢ÔÚ»¥³âÁ¿µÄ»ù´¡Ö®ÉÏ£¬Í¬Ê±¼ÓÈëÖØÒªÌØÐÔ£ºÌṩÁË×ÊÔ´¼ÆÊý¹¦ÄÜ£¬Òò´ËÔ¤¶¨ÒåÊýÁ¿µÄÏß³Ìͬʱ¿ÉÒÔ½øÈëͬ²½µÄ´úÂë¿éÖС£
ÐźÅÁ¿ÊÇά»¤0µ½Ö¸¶¨×î´óÖµÖ®¼äµÄ¼ÆÊýÆ÷µÄͬ²½¶ÔÏ󣬵±Ïß³ÌÍê³ÉÒ»´ÎÐźÅÁ¿µÄµÈ´ýʱ£¬¼ÆÊýÆ÷×Ô¼õ1£¬µ±Ïß³ÌÊÍ·ÅÐźÅÁ¿¶ÔÏóʱ£¬¼ÆÊýÆ÷×ÔÔö1¡£
......