Delphi利用字符串序列号对象
生活随笔
收集整理的這篇文章主要介紹了
Delphi利用字符串序列号对象
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天因為工作需要,原先調用動態庫的方法已經寫死了,只有兩個字符串參數,現在想把串口對象傳到動態庫里面去,在動態庫里面直接收發數據,經過百度一番,重要出了下面的解決方案,不多說 上源碼
Q群 Delphi Home 235236282,歡迎delphi 愛好者加入,一起學習、進步。
unit umain;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, SPComm;typeTForm1 = class(TForm)cm1: TComm;btn1: TButton;btn2: TButton;btn3: TButton;procedure btn1Click(Sender: TObject);procedure btn2Click(Sender: TObject);procedure btn3Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;lsHandle: string;implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject); beginlsHandle := IntToStr(THandle(cm1)); end;procedure TForm1.btn2Click(Sender: TObject); varcm: TComm;lihandle: Integer; beginlihandle := StrToInt(lsHandle);cm := TComm(lihandle);ShowMessage(inttostr(cm.BaudRate));cm.BaudRate:=7200; end;procedure TForm1.btn3Click(Sender: TObject); beginShowMessage(inttostr(cm1.BaudRate)); end;end.?
object Form1: TForm1Left = 192Top = 130Width = 272Height = 170Caption = 'Form1'Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'MS Sans Serif'Font.Style = []OldCreateOrder = FalsePixelsPerInch = 96TextHeight = 13object btn1: TButtonLeft = 56Top = 8Width = 75Height = 25Caption = '保存句柄'TabOrder = 0OnClick = btn1Clickendobject btn2: TButtonLeft = 56Top = 40Width = 75Height = 25Caption = '還原對象'TabOrder = 1OnClick = btn2Clickendobject btn3: TButtonLeft = 56Top = 72Width = 169Height = 25Caption = '驗證是否同一個對象'TabOrder = 2OnClick = btn3Clickendobject cm1: TCommCommName = 'COM2'BaudRate = 4800ParityCheck = FalseOutx_CtsFlow = FalseOutx_DsrFlow = FalseDtrControl = DtrEnableDsrSensitivity = FalseTxContinueOnXoff = TrueOutx_XonXoffFlow = TrueInx_XonXoffFlow = TrueReplaceWhenParityError = FalseIgnoreNullChar = FalseRtsControl = RtsEnableXonLimit = 500XoffLimit = 500ByteSize = _8Parity = NoneStopBits = _1XonChar = #17XoffChar = #19ReplacedChar = #0ReadIntervalTimeout = 100ReadTotalTimeoutMultiplier = 0ReadTotalTimeoutConstant = 0WriteTotalTimeoutMultiplier = 0WriteTotalTimeoutConstant = 0Left = 16Top = 8end endQ群 Delphi Home 235236282,歡迎delphi 愛好者加入,一起學習、進步。
總結
以上是生活随笔為你收集整理的Delphi利用字符串序列号对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CSS 特异性看这篇就行了
- 下一篇: 科学绘图经典--Grapher