procedure TForm1.Button2Click(Sender: TObject);<br>var<br> h, YH, MH, DH, BtnH, LblH, TMPH: THandle;<br> s, i, Y, M, D, DAYCount, Charcount: integer;<br> sl: TstringList;<br> str, strY, strM, strD, nowstr, oldSTR: string;<br> p: PChar;<br><br>begin<br> Button2.Enabled := false;<br> YH := StrToInt(Edit1.Text);<br> MH := StrToInt(Edit2.Text);<br> DH := StrToInt(Edit3.Text);<br> BtnH := StrToInt(Edit4.Text);<br> LblH := StrToInt(Edit5.Text);<br> p := GetMemory(255);<br> sl := TStringList.Create;<br> for s := 10 downto 2 do<br> begin<br> sl.Clear;<br><br> for i := 0 to 99 do<br> begin<br> Y := s * 100 + i;<br><br><br> SendMessage(YH, WM_SETTEXT, 0, longint(pchar(inttostr(Y))));<br> strY := inttostr(Y);<br> for m := 1 to 12 do<br> begin<br> SendMessage(MH, WM_SETTEXT, 0, longint(pchar(inttostr(M))));<br> strM := RightStr('00' + inttostr(m), 2);<br> if m = 2 then<br> begin<br> if y mod 4 = 0 then<br> DAYCount := 29<br> else<br> DAYCount := 28;<br> end<br> else<br> if m in [1, 3, 5, 7, 8, 10, 12] then<br> DAYCount := 31<br> else<br> DAYCount := 30;<br> Sleep(30);<br> Application.ProcessMessages;<br> <br> for D := 1 to DAYCount do<br> begin<br> SendMessage(DH, WM_SETTEXT, 0, longint(pchar(inttostr(D))));<br><br> SendMessage(BtnH, BM_CLICK, 0, 0);<br><br> strD := RightStr('00' + inttostr(d), 2);<br> Charcount := 255;<br> GetWindowText(LblH, p, Charcount);<br> str := strY + '-';<br> str := str + strM;<br> str := str + '-';<br> str := str + strD;<br> str := str + '=';<br> nowstr := StrPas(p);<br> nowstr := StringReplace(nowstr, #13, ',',[rfReplaceAll]);<br> nowstr := StringReplace(nowstr, #10, ',',[rfReplaceAll]);<br><br> if oldSTR &lt;&gt; nowstr then<br> begin<br> str := str + nowstr;<br> oldSTR := nowstr;<br><br> end<br> else<br> begin<br><br> h := 0;<br> h := FindWindowEx(GetParent(yh),0, nil, '两千年中西历速查');<br> if h &lt;&gt; 0 then<br> SendMessage(h, WM_CLOSE, 0, 0);<br><br> end;<br> sl.Add(str);<br> end;<br> end;<br> end;<br> sl.SaveToFile('c:/' + inttostr(s) + '.TXT');<br><br> end;<br><br><br> FreeAndNil(sl);<br>end;<br>