我在线程里声明一个控件对象,首先在USESE里面引用了“MSCommLib_TLB”,然后再引用"ACTIVEX",接下来如下面的程序所示:
procedure colThread.Execute;
begin
FreeOnTerminate:=True;
TColTMSComm.Create(Application);
ColMSComm.InputLen :=1;
ColMSComm.RThreshold :=1;
ColMSComm.Settings :='9600,o,8,1';
if colMSComm.PortOpen =false then
colMSComm.PortOpen :=True;
if(timeBeginPeriod(nTimerRes)=TIMERR_NOERROR) then
begin
nTimerID:=timeSetEvent(SamplePeriod,nTimerRes,@TimeProc,0,TIME_PERIODIC);//启动定时器
end;
end;
initialization
CoInitialize(nil);
finalization
CoUnInitialize;
end.可是还是会出现“尚未调用CoInitialize”,请问一下这个是什么问题啊,搞了一个晚上了,深夜发贴
procedure colThread.Execute;
begin
FreeOnTerminate:=True;
TColTMSComm.Create(Application);
ColMSComm.InputLen :=1;
ColMSComm.RThreshold :=1;
ColMSComm.Settings :='9600,o,8,1';
if colMSComm.PortOpen =false then
colMSComm.PortOpen :=True;
if(timeBeginPeriod(nTimerRes)=TIMERR_NOERROR) then
begin
nTimerID:=timeSetEvent(SamplePeriod,nTimerRes,@TimeProc,0,TIME_PERIODIC);//启动定时器
end;
end;
initialization
CoInitialize(nil);
finalization
CoUnInitialize;
end.可是还是会出现“尚未调用CoInitialize”,请问一下这个是什么问题啊,搞了一个晚上了,深夜发贴
使用方法:
procedure colThread.Execute;
begin
coInitialize(nil);
try FreeOnTerminate:=True;
TColTMSComm.Create(Application);
ColMSComm.InputLen :=1;
ColMSComm.RThreshold :=1;
ColMSComm.Settings :='9600,o,8,1';
if colMSComm.PortOpen =false then
colMSComm.PortOpen :=True;
if(timeBeginPeriod(nTimerRes)=TIMERR_NOERROR) then
begin
nTimerID:=timeSetEvent(SamplePeriod,nTimerRes,@TimeProc,0,TIME_PERIODIC);//启动定时器
end;
finally
CoUninitialize;
end;end.
要先 Initialize(nil); 在create