N
nanshan
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm_dingshi.TimerTimer(Sender: TObject);<br>var<br> i: integer;<br> runtime,ntime: Tdatetime;<br> sm:string;<br>begin<br> if ListViewbusy then<br> Exit;<br> Label2.Caption := '当前时间:' + DateTimeToStr(Now);<br> for i := 0 to ListView1.Items.Count - 1 do<br> begin<br> runtime := StrToDateTime(ListView1.Items.SubItems.Strings[0]);<br> ntime := Now;<br> if SecondsBetween(runtime, ntime) =0 then<br> begin<br> Form_main.LoadfileTimeliat;<br> sm:= ListView1.Items.SubItems.Strings[2];<br> ShellExecute(Application.handle, 'open', PChar(sm), nil, nil, SW_ShowNormal);///就是这句话,执行一次打开两次文件。<br> end;<br> end;<br>end;<br><br>如果用时间控件触发就会执行一次,工作两次。<br><br>procedure TForm_dingshi.Button2Click(Sender: TObject);<br>var<br> i: integer;<br> runtime,ntime: Tdatetime;<br> sm:string;<br>begin<br> Label2.Caption := '当前时间:' + DateTimeToStr(Now);<br> for i := 0 to ListView1.Items.Count - 1 do<br> begin<br> runtime := StrToDateTime(ListView1.Items.SubItems.Strings[0]);<br> ntime := Now;<br> if SecondsBetween(runtime, ntime) =0 then<br> begin<br> Form_main.LoadfileTimeliat;<br> sm:= ListView1.Items.SubItems.Strings[2];<br> ShellExecute(Application.handle, 'open', PChar(sm), nil, nil, SW_ShowNormal);<br> end;<br> end;<br>end;<br><br>这样放到按钮下就可以执行一次打开一次了。<br><br>我保证时间控件是执行了一次却打开文件两次。<br>高手帮忙看看呀。实在是糊涂了。