ÓÃSPCOMM ÔÚ DelphiÖÐʵÏÖ´®¿ÚͨѶ
ÓÃDelphi ʵÏÖ´®¿ÚͨѶ£¬³£Óõļ¸ÖÖ·½·¨Îª£ºÊ¹ÓÿؼþÈçMSCOMMºÍSPCOMM£¬Ê¹ÓÃAPIº¯Êý»òÕßÔÚDelphi Öе÷ÓÃÆäËü´®¿ÚͨѶ³ÌÐò¡£ÀûÓÃAPI±àд´®¿ÚͨÐųÌÐò½ÏΪ¸´ÔÓ£¬ÐèÒªÕÆÎÕ´óÁ¿Í¨ÐÅ֪ʶ£¬ÆäÓŵãÊÇ¿ÉʵÏֵŦÄܸüÇ¿´ó£¬Ó¦ÓÃÃæ¸ü¹ã·º£¬¸üÊʺÏÓÚ±àд½ÏΪ¸´ÔÓ µÄµÍ²ã´ÎͨÐųÌÐò¡£Ïà±È½Ï¶øÑÔ£¬ÀûÓÃSPComm¿Ø¼þÔòÏà¶Ô½Ï¼òµ¥£¬¸Ã¿Ø¼þ¾ßÓзḻµÄÓë´®¿ÚͨÐÅÃÜÇÐÏà¹ØµÄÊôÐÔ¼°Ê¼þ£¬ÌṩÁ˶Դ®¿ÚµÄ¸÷ÖÖ²Ù×÷¡£
¡¡¡¡Ê¹ÓÿؼþÕâÒ»·½·¨ÈÝÒ×ÕÆÎÕ£¬¶øSPCOMMÖ§³Ö¶àỊ̈߳¬ËùÒÔSPCOMM¿Ø¼þµÄÓ¦Óøü¼Ó¹ã·º¡£½áºÏʵÀýÏêϸ½éÉÜSPCOMMµÄʹÓá£
Ò»£®SPCOMM¿Ø¼þµÄ°²×°
1£®Ñ¡ÔñÏÂÀ²Ëµ¥ComponentµÄµÚ¶þÏîInstall Component ¡£
ͼ1
µ¯³öͼ1ËùʾµÄ´°¿Ú,ÔÚUnit file name ´¦Ìîд¿Ø¼þSPCOMM¿Ø¼þËùÔÚ·¾¶£¬ÆäËü¿ÉÓÃĬÈÏÖµ£¬µã»÷OK°´Å¦¡£
2£®°²×°³É¹¦ºó£¬system¿Ø¼þÃæ°åÖн«³öÏÖÒ»¸öºìÉ«¿Ø¼þCOMM¡£ÏÖÔÚʹÓÃCOMM¿Ø¼þ¿ÉÒÔÏóDelphi×Ô´ø¿Ø¼þÒ»ÑùʹÓá£
¶þ£®SPCOMMµÄÖ÷ÒªÊôÐÔ£¬·½·¨ºÍʼþ
1.ÊôÐÔ
CommName£ºÌîдCOM1,COM2…µÈ´®¿ÚµÄÃû×Ö,ÔÚ´ò¿ª´®¿ÚÇ°£¬±ØÐëÌîдºÃ´ËÖµ¡£
BaudRate:É趨²¨ÌØÂÊ9600£¬4800µÈ£¬¸ù¾Ýʵ¼ÊÐèÒªÀ´¶¨£¬ÔÚ´®¿Ú´ò¿ªºóÒ²¿É¸ü¸Ä²¨ÌØÂÊ£¬Êµ¼Ê²¨ÌØÂÊËæÖ®¸ü¸Ä¡£
ParityCheck£ºÆæżУÑé¡£
ByteSize£º×Ö½Ú³¤¶È_5,_6,_7,_8µÈ£¬¸ù¾Ýʵ¼ÊÇé¿öÉ趨¡£
Parity£ºÆæżУÑéλ
pBits£ºÍ£Ö¹Î»
SendDataEmpty£ºÕâÊÇÒ»¸ö²¼¶ûÊôÐÔ£¬Îªtrueʱ±íʾ·¢ËÍ»º´æΪ¿Õ£¬»òÕß·¢ËͶÓÁÐÀïûÓÐÐÅÏ¢£»ÎªFalseʱ±íʾ±íʾ·¢ËÍ»º´æ²»Îª¿Õ£¬»òÕß·¢ËͶÓÁÐÀïÓÐÐÅÏ¢¡£
2£®·½·¨
¡¡¡¡Startcomm¹ý³ÌÓÃÓÚ´ò¿ª´®¿Ú£¬µ±´ò¿ªÊ§°Üʱͨ³£»á±¨´í£¬´íÎóÖ÷ÒªÓÐ7ÖÖ£º
¢Å´®¿ÚÒѾ´ò¿ª £»
¢Æ´ò¿ª´®¿Ú´íÎó £»
¢ÇÎļþ¾ä±ú²»ÊÇͨѶ¾ä±ú£»
¢È²»Äܹ»°²×°Í¨Ñ¶»º´æ£»
¢É²»ÄܲúÉúʼþ £»
¢Ê²»ÄܲúÉú¶Á½ø³Ì£»
¢Ë²»ÄܲúÉúд½ø³Ì£»
¡¡¡¡StopComm¹ý³ÌÓÃÓڹرմ®¿Ú£¬Ã»Óзµ»ØÖµ¡£
¡¡¡¡º¯ÊýWriteCommData(pDataToWrite: PChar;dwSizeofDataToWrite:Word ): boolean ÓÃÓÚ·¢ËÍÒ»¸ö×Ö·û´®µ½Ð´Ị̈߳¬·¢Ëͳɹ¦·µ»Øtrue,·¢ËÍʧ°Ü·µ»Øfalse, Ö´Ðд˺¯Êý½«Á¢¼´µÃµ½·µ»ØÖµ£¬·¢ËͲÙ×÷ËæºóÖ´ÐС£º¯ÊýÓÐÁ½¸ö²ÎÊý£¬ÆäÖÐ pdatatowriteÊÇÒª·¢Ë͵Ä×Ö·û´®£¬dwsizeofdatatowrite ÊÇ·¢Ë͵ij¤¶È¡£
3£®Ê¼þ
OnReceiveData : procedure (Sender: TObject;Buffer: Pointer;BufferLength: Word) of object¡¡
µ±ÊäÈ뻺´æÓÐÊý¾Ýʱ½«´¥·¢¸Ãʼþ£¬ÔÚÕâÀï¿ÉÒÔ¶Ô´Ó´®¿ÚÊÕµ½µÄÊý¾Ý½øÐд¦Àí¡£BufferÖÐÊÇÊÕµ½µÄÊý¾Ý£¬bufferlengthÊÇÊÕµ½µÄÊý¾Ý³¤¶
Ïà¹ØÎĵµ£º
¼¼Êõ½»Á÷,DH½²½â. ¹þ¹þ,ÎÒ³ÐÈÏÎÒÊDZêÌâµ³.
×î½ü¿´ÌìÊéÒ¹¶ÁÀïÃæÊǶÔCÓïÑԵĴúÂë·´»ã±à,²»´í,¿ÉϧDelphiûÓÐÕâÑùµÄÊé,ÄÇÎÒÃÇ×Ô¼º¶¯ÊÖ°É.
Ê×ÏȽøÈëForÑ»·ÁË. Function TestFor( a, b: Integer ): Integer ;
Var
I: Integer ;
Begin
Result := a + b ;
For I := 0 To 49 Do
Result := Result + I ......
¼¼Êõ½»Á÷,DH½²½â. Õâ¸öÊÇÔÚCSDNÉÏÃæ¿´¼ûµÄÎÊÌâ.ÎÒ˵˵×Ô¼ºµÄÏë·¨. procedure TForm1.btn1Click(Sender: TObject);
var
Str:String;
begin
Str:='abc' ;
Str:=str+'d';
str:=copy(Str,1,3);
str:=UpperCase(str);
end;
ÎÊÌâ1´ð°¸:2010ÏÂ
Unit4.pas.29: begin
005144E0 55 p ......
ʵ¼ÊÉÏÕâ¸öÃû×Ö½Ð[SDL & Delphi]Ò²²»³ÉÎÊÌ⣬ ÒòΪ³ýÁËDelphiËƺõҲûÓÐÄĸöÁ÷ÐеĿª·¢¹¤¾ßÓõÄÊÇPascalÓïÑÔ¡£
SDLÆäʵÎÒҲֻѧÁ˲»µ½Á½ÐÇÆÚ¶øÒÑ¡£¸Õ¿ªÊ¼ÎÒÏëÊÔͼÓÃVC£¬ÒòΪÕâÑù×ÊÁÏ×îÈ«£¬Ò²ºÜºÃÕÒ£¬µ«Ì«¾ÃûÓÃVCÏÖÔÚ¿´CµÄ´úÂëÓеãÀ§ÄÑ£¨->Õâ¸öËã·ûÊǸÉÂðµÄÀ´×Å……£©¡£Æäʵ×÷Ϊһ¸öרҵ²»ÊǼÆËã»úµÄÈË ......
Ò»¸öÑ¡µ¥´óÖÂÊÇÕâÑù£º
1.¿ÉÒÔ±»ÒÔijÖÖÐÎʽºô½Ð³öÀ´£¬Èç°´ÏÂesc£»
2.ÔÚÕâ¸öÑ¡µ¥Öй¦ÄܼüÓв»Í¬µÄ¶¨Ò壬ÈçÔ±¾·½Ïò¼ü¿ØÖÆ×ß·£¬µ«ÏÖÔÚ¸ÄΪ¿ØÖƹâ±êµÄλÖã»
3.°´ÏÂÈ·¶¨¼üºóÓжÔÓ¦¹¦Äܱ»Ö´ÐУ»
4.¿ÉÒÔ±»¹Ø±Õ¡£
ÄÇôÎҵİ취ÊDZàдÁ½¸ö×ӳ̣¬ÆäÖÐÒ»¸ö´¦ÀíÑ¡µ¥ÖеÄʼþ£¬ÁíÍâÒ»¸öרߺÔð»Ñ¡µ¥¡£
ÔÚ´Ó²½ÐÐÇл»µ½Ñ¡µ¥ ......