模拟点击下载一个文件,为什么有时候会报错,有时候又不会
模拟点击下载一个文件,为什么有时候会报错,有时候又不会Project C:\Documents and Settings\Administrator\桌面\Project1.exe faulted with message:'access violation at 0x7d5c9b36:read of address 0xfeeefeee'. Process Stopped. Use Step or Run to continue.下载的文件是根据时间自动命名的。
void __fastcall TForm1::tmr1Timer(TObject *Sender){ HWND lngFrmHwnd=0 ; HWND lngBtnHwnd=0 ; HWND lngFrmHwnd1=0 ; HWND lngBtnHwnd1=0 ; HWND lngFrmHwnd2=0 ; HWND lngBtnHwnd2=0 ; lngFrmHwnd=FindWindow(NULL,"文件下载"); lngBtnHwnd=FindWindowEx(lngFrmHwnd,0,"BUTTON","保存(&S)"); if (!lngBtnHwnd==0) { SendMessage(lngBtnHwnd,WM_LBUTTONDOWN,0,0); SendMessage(lngBtnHwnd,WM_LBUTTONUP,0,0); } try { lngFrmHwnd1=FindWindow(NULL,"另存为"); lngBtnHwnd1=FindWindowEx(lngFrmHwnd1,0,"BUTTON","保存(&S)"); } catch(...) {}; if (!lngBtnHwnd1==0) { SendMessage(lngBtnHwnd1,WM_LBUTTONDOWN,0,0); SendMessage(lngBtnHwnd1,WM_LBUTTONUP,0,0); } lngFrmHwnd2=FindWindow(NULL,"下载完毕"); lngBtnHwnd2=FindWindowEx(lngFrmHwnd2,0,"BUTTON","关闭"); if (!lngBtnHwnd2==0) { SendMessage(lngBtnHwnd2,WM_LBUTTONDOWN,0,0); SendMessage(lngBtnHwnd2,WM_LBUTTONUP,0,0); }}