Delphi¶àÏß³Ìѧϰ£¨4£©£ºÁÙ½çÇø
ÁÙ½çÇøÊÇÒ»¶Î´úÂ룬һ´ÎÖ»ÔÊÐíÒ»¸öÏß³ÌÖ´ÐÐÕâ¶Î´úÂë¡£µ±°ÑÒ»¶Î´úÂë·ÅÈëÒ»¸öÁÙ½çÇø, Ïß³ÌÖ´Ðе½ÁÙ½çÇøʱ¾Í¶ÀÕ¼ÁË, ÆäËûÏß³ÌÈç¹ûÒª·ÃÎÊÕâ¶Î´úÂ룬һ¶¨ÒªµÈÇ°Ò»¸ö·ÃÎʵÄÏ߳̽áÊø²ÅÐС£½èÓÃÇ°ÃæµÄ±ÈÓ÷±È×÷ͼÊé¹Ý£¬ÁÙ½çÇø¾ÍÏñ°ÑͼÊé¹ÝÉè¼Æ³ÉÖ»ÓÐÒ»¸öλÖã¨ÏÖʵÖкÃÏñ²»Ì«ºÏÀí£¬²»¹ÜÁË£¬·´ÕýÕâô¸öÒâ˼£©£¬µ±ÓÐÒ»¸öÈËÕýÔÚ°ìÀíÒµÎñʱ£¬ÆäËûÈËÖ»ÄܵȴýÄǸöÈË°ìÍêÒµÎñ²ÅÄܽøÈ¥¡£
ʹÓÃÁÙ½çÇøµÄ²½Ö裺
1¡¢ÉùÃ÷Ò»¸öTRLCriticalSection¼Ç¼ÀàÐ͵ıäÁ¿ÈçCS£¬±ØÐëÊÇÈ«¾ÖµÄ£»
2¡¢Ê¹ÓÃÇ°Ïȳõʼ»¯£ºInitializeCriticalSection(CS)£»
3¡¢EnterCriticalSection(CS); Ï߳̽øÈëÁÙ½çÇø£¬ÆäËûÏß³ÌÐèÒªµÈ´ý
4¡¢LeaveCriticalSection(CS); Ïß³ÌÀ뿪ÁÙ½çÇø£¬ÆäËûÏ߳̿ÉÒÔ·ÃÎÊÁË
5¡¢DeleteCriticalSection(CS); ×îºóɾ³ýÁÙ½çÇø
ÖØдǰÎĵÄÀý×Ó£¬ÈçÏ£º
{Ö÷´°Ìå´úÂë}
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
CS:TRTLCriticalSection; //È«¾ÖÁÙ½çÇø±äÁ¿
implementation
uses MyThread;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
TMyThread.Create(False);
TMyThread.Create(False);
TMyThread.Create(False);
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
InitializeCriticalSection(CS); //³õʼ»¯
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
DeleteCriticalSection(CS); //ɾ³ý
end;
end.{Ïß³ÌÀà}
unit MyThread;
interface
uses
Classes,StdCtrls,SysUtils,Windows;
type
TMyThread = class(TThread)
private
{ Private declarations }
str:String;
procedure AddList;
protected
procedure Execute
Ïà¹ØÎĵµ£º
ÔÚ±àÒëdelphi³ÌÐòʱ»á³öÏÖÔÚЩÌáʾ£¬È«ÊÇEÎĵģ¬ÏÖÔÚ¸ø´ó¼ÒÒ»¸ö¶ÔÕÕ±í£¬¿ÉÒÔ¸üºÃµÄÀí½â´íÎóÌáʾÐÅÏ¢£¡
';' not allowed before 'ELSE' ElSEÇ°²»ÔÊÐíÓГ;”
'' clause not allowed in OLE automation section ÔÚOLE×Ô¶¯Çø¶Î²»ÔÊÐí“”×Ó¾ä
'' is not a type identifier ²»ÊÇÀàÐͱêʶ·û
'' not prev ......
һЩ»ù´¡µÄÎÊÌâÎÒ²»ÔÙ׸ÊöÁË£¬²éÔÄ°ïÖúÎĵµ£¨Object Pascal SDL Doc.chm£©ÏÔÈ»±ÈÔÚÕâ¿´ÎÒºú³¶ºÏÊʵöࡣÄÇЩ»ÏñËØ£¬»ñÈ¡ÏñËØÐÅÏ¢£¬ÏÔʾBMPÎļþ¶àÊýʱºòÖ»Òª°ÑÄÇЩ´úÂ븴ÖƹýÀ´»ù±¾¾ÍÄܹ¤×÷¡£ÏÂÃæ˵µÄÊÇÔõÑùÏÔʾÖÐÎÄ¡£
ÆäʵSDL¼ÓÉÏttfÖ§³Öʱ£¨ÐèÒª½«¶ÔÓ¦µÄdllÎļþÌí¼Óµ½¹¤³ÌĿ¼ÀÊÇÍêÈ«¿ÉÒÔÏÔʾÖÐÎĵģ¬¼òÌåºÍ·±Ì嶼ûΠ......
ÓÃDelphi ʵÏÖ´®¿ÚͨѶ£¬³£Óõļ¸ÖÖ·½·¨Îª£ºÊ¹ÓÿؼþÈçMSCOMMºÍSPCOMM£¬Ê¹ÓÃAPIº¯Êý»òÕßÔÚDelphi Öе÷ÓÃÆäËü´®¿ÚͨѶ³ÌÐò¡£ÀûÓÃAPI±àд´®¿ÚͨÐųÌÐò½ÏΪ¸´ÔÓ£¬ÐèÒªÕÆÎÕ´óÁ¿Í¨ÐÅ֪ʶ£¬ÆäÓŵãÊÇ¿ÉʵÏֵŦÄܸüÇ¿´ó£¬Ó¦ÓÃÃæ¸ü¹ã·º£¬¸üÊʺÏÓÚ±àд½ÏΪ¸´ÔÓ µÄµÍ²ã´ÎͨÐųÌÐò¡£Ïà±È½Ï¶øÑÔ£¬ÀûÓÃSPComm¿Ø¼þÔòÏà¶Ô½Ï¼òµ¥£¬¸Ã¿Ø¼þ¾ßÓ ......
¹ØÓÚdelphi Assigned
1.¸ù¾Ý Delphi Ö¸Áî²Î¿¼ÊÖ²áÖÐ
˵Ã÷£º
Assigned º¯Ê½ÔÚ²ÎÊý²»Îªnilʱ´«»ØTrue,±íʾָÕëÒѾָµ½Ä³¸öÄÚ´æµØÖ·£¬Õâ¸öÄÚ´æµØÖ·¿ÉÄÜÊÇÒ»¸ö¶ÔÏóµØÊ×µØÖ·£¬Ò²¿ÉÄÜÔÚº¯Êý»ò¹ý³ÌÖУ¬ÉùÃ÷Ò»¸öÖ¸Õë±äÁ¿£¬Ã»Óи³ÖµÎªnil £¬ÎÞÂÒµÄÖ¸Ïòij´¦£¬ÕâÁ½¸öÖÖÇé¿ö£¬Assigned£¨Ö¸Õë±äÁ¿£©¶¼²»Îªnil , º¯Êý·Å»ØTrue£»
¶ø² ......
http://www.91v1.cn/bbs/read.php?tid-1797.html
ÎÒÃÇÌṩµÄÊÇÈ«Ì×,Ä¿Ç°ËûÃÇ·¢µÄ.ÉçÇøÒѼÖÆÍê±Ï.Ò»¸ùë²»ÉÙ.
-------------------------------------------------------------------------------------------------------------------------
¸Ã½Ì³ÌÓÉ91v1ÉçÇøÃâ·ÑÌṩ.¾ßÌåÃâ·ÑÁìÂëÏêÇé¹Û¿´ÖÖ×Ó°ü,
--------------- ......