亚洲欧美日韩国产成人|亚洲中文字幕无码中字|HEYZO在线无码综合|久久久不卡精品国产一区二|久久精品亚洲无中文东京热|中文字幕乱码一区三区免费|亚洲国产欧美在线观看片不卡|国产精品久久一区二区三区97

快來看(長沙十大名中學)法院政工干部個人工作總結(jié),解決InternetOpenUrl卡住的問題,2021nba季后賽對陣圖安排,

保健品 nanfang 2023-06-27 02:10 144 0

1.長沙市中院法官名冊

在用InternetOpenUrl下載網(wǎng)頁的時候,一般網(wǎng)頁打不開的時候該函數(shù)都會正常返回,但是偶爾會出現(xiàn)網(wǎng)頁打不開的時候,程序就一直停在那里,導致本來計劃好的下載任務都沒有正常進行下去,代碼如下:網(wǎng)頁下載類的主要代碼:

2.長沙市中級人民法院法官名冊

ibol CMyWeb3::Get(蓮花橋 iHInternet hSession, char *psUrl, iuint flag ){ m_ps[0] = \0; m_len = 0; iHInternet hFile = InternetOpenUrlA( hSession, psUrl, inull, 0, flag, 1);

3.長沙市中級人民法院領導排名

if( hFile==inull ) { P( "InternetOpenUrlA fail" ); return 0; } ReadData( hFile ); InternetCloseHandle( hFile );

4.長沙中院員額法官名單

if( m_len<=0 ) 蓮花橋{ P( " m_len<=0 " ); return 0; } return 1;}void CMyWeb3::ReadData( iHInternet hFile )

5.長沙市中級人民法院政治處

{ int len = 0; int ci = 0; while( ci<30 ) { m_len = 0; if( !InternetReadFile( hFile, (void*)(&m_ps[len]), 1024, &m_len) )

6.長沙市中級人民法院執(zhí)行局副局長名單

{ P_Err(); ci++; Sleep( 100 ); continue; } if( m_len<=0 ) { c蓮花橋i++; Sleep( 100 ); continue; } len = len + m_len;

7.現(xiàn)任長沙中級法院領導名單

} if( len>0 ) { m_ps[len] = \0; m_len = len; } else { m_len = 0; m_ps[0] = \0; }}具體操作類:class CDoNr{public:

8.長沙市中院執(zhí)行局法官名單

iSystemTime m_tm;private: int m_NrId; char *m_ps; int m_len; CMyDb m_db; CMyWeb3 m_web; iHInternet m_hSession;

9.長沙市中級蓮花橋人民法院政治處電話

public: void Get( int id ); void Init();private: ibol Get1( char *psWz, char *psBt );public: CDoNr();

10.長沙市中級法院領導名單

~CDoNr();};CDoNr::CDoNr(){ m_len = 8192 * 2000; m_ps = new char[m_len]; m_hSession = inull;}CDoNr::~CDoNr()

{ Del_Zu( m_ps ); if( m_hSession!=inull ) InternetCloseHandle( m_hSes蓮花橋sion );}void CDoNr::Init(){ ::GetLocalTime( &m_tm );

m_hSession = InternetOpenA( "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)", iPre_Config_Internet_Access, inull, inull, 0);

char s[1024]; sprintf_s( s, 1024, "%s\\Dt\\db.mdb", g_can.m_dir ); m_db.OpenAccess( s );}void CDoNr::Get( i蓮花橋nt id )

{ //從數(shù)據(jù)庫中讀取網(wǎng)頁 char wz[1024], bt1[1024], bt2[1024], s[1024]; int min = id * 10000, max = (id+1) * 10000;

sprintf_s( s, 1024, "Select * from Nr where DownOk=0 and IDME>=%d and IDME<=%d ", min, max ); m_db.Open( s );

int shu = m_db.m_set.m_set->RecordCount; int ge = 0; while( !m_db.adoEOF() ) { if蓮花橋( g_can.m_stop ) { P("暫停退出 1");

break; } ::GetLocalTime( &m_tm ); m_db.Get( "wz", wz, 1024 ); //獲取網(wǎng)址 m_db.Get( "ming", bt1, 1024 ); m_db.Get( "IDME", m_NrId );

P1("------- %d & %d / %d------", ge++, m_NrId, shu ); if( Get1( wz, bt2 ) ) { m_db.Put( "DownOk", 1 );

m_db.Put( "ming", bt1 ); m_db.Update(); 蓮花橋} m_db.MoveNext(); } m_db.Close(); P("已成功完成");}//ibol CDoNr::Get1( char *psWz, char *psBt )

{ char s[1024]; if( !m_web.Get( m_hSession, psWz ) ) { P("下載失敗"); return 0; }..... return 1;}看一下InternetOpenUrl的函數(shù)說明:InternetOpenUrl:Opens a resource specified by a complete FTP, Gopher, or HTTP URL.打開 Url,讀取數(shù)蓮花橋據(jù)

hInternet :[in] Handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen. 當前的 Internet 會話句柄。

句柄必須由前期的 InternetOpen 調(diào)用返回 lpszUrl :[in] Pointer to a null-terminated string variable that specifies the URL to begin reading. Only URLs beginning with ft蓮花橋p:, gopher:, http:, or https: are supported. 一個空字符結(jié)束的字符串變量的指針,指定讀取的網(wǎng)址。

只有以ftp:, gopher:, http:, 或者 https: 開頭的網(wǎng)址被支持 lpszHeaders :[in] Pointer to a null-terminated string that specifies the headers to be sent to the HTTP server. (For more information, see the description of the lpszHeaders parameter in蓮花橋 the HttpSendRequest function.) 一個空字符結(jié)束的字符串變量的指針,指定發(fā)送到HTTP服務器的頭信息。

欲了解更多信息,請參閱HttpSendRequest函數(shù)里lpszHeaders參數(shù)的說明 dwHeadersLength:[in] Size of the additional headers, in TCHARs. If this parameter is -1L and lpszHeaders is not NULL, lpszHeaders is assumed to be zero-terminated (ASCIIZ) and the length i蓮花橋s calculated.

dwContext :[in] Pointer to a variable that specifies the application-defined value that is passed, along with the returned handle, to any callback functions. 一個指向一個應用程序定義的值,將隨著返回的句柄,一起傳遞給回調(diào)函數(shù)

Returns a valid handle to the FTP, Gopher, or HTTP URL if the connection is successfully establi蓮花橋shed, or NULL if the connection fails. To retrieve a specific error message, call GetLastError. To determine why access to the service was denied, call InternetGetLastResponseInfo.如果已成功建立到FTP,Gopher,或HTTP URL的連接,返回一個有效的句柄,如果連接失敗返回NULL。

要檢索特定的錯誤訊息,請GetLastError 要確定為什么對服務器的訪問被拒絕,請調(diào)用InternetGetLastRespo蓮花橋nseInfo Call InternetCanonicalizeUrl first if the URL being used contains a relative URL and a base URL separated by blank spaces.先調(diào)用InternetCanonicalizeUrl,如果正在使用的網(wǎng)址包含一個相對URL和一個空格分隔的基礎URL

This is a general function that an application can use to retrieve data over any of the protocols that WinINet s蓮花橋upports. This function is especially useful when the application does not need to access the particulars of a protocol, but only requires the data corresponding to a URL. The InternetOpenUrl function parses the URL string, establishes a connection to the server, and prepares to download the data ide蓮花橋ntified by the URL. The application can then use InternetReadFile (for files) or InternetFindNextFile (for directories) to retrieve the URL data. It is not necessary to call InternetConnect before InternetOpenUrl.這是一個通用的函數(shù),可用于使用任何WinINet支持的協(xié)議檢索數(shù)據(jù)。

這個函數(shù)在應用程序并不需要指定特定的協(xié)議,只需要相應的URL的數(shù)據(jù)時,特別有用InternetOpenUr蓮花橋l函數(shù)解析URL字符串,建立連接到服務器,并準備下載的指定URL的數(shù)據(jù)該應用程序可以用InternetReadFile (對文件)或InternetFindNextFile (對目錄)來檢索URL的數(shù)據(jù)。

沒有必要在InternetOpenUrl 前調(diào)用InternetConnect InternetOpenUrl disables Gopher on ports less than 1024, except for port 70—the standard Gopher port—and port 105—typically used for Central Services Organiza蓮花橋tion (CSO) name searches.InternetOpenUrl在少于1024端口上禁用Gopher,除了70——標準的Gopher端口和105——通常用于中央服務組織(民間組織)的名字搜索

After the calling application has finished using the HINTERNET handle returned by InternetOpenUrl, it must be closed using the InternetCloseHandle function.在使用完InternetOpenUrl返回的HINTERNET句柄后,必須使用In蓮花橋ternetCloseHandle函數(shù)關(guān)閉它。

注意 :當工作在異步模式(InternetOpen的dwFlags參數(shù)指定INTERNET_FLAG_ASYNC)和dwContext參數(shù)是零 (INTERNET_NO_CALLBACK),使用InternetSetStatusCallback函數(shù)設置的回調(diào),將不被引用,但是,將仍然在異步模式執(zhí)行回調(diào)。

好像沒有對解決這個問題有幫助的信息為了解決InternetOpenUrl卡住的問題,嘗試了設置超時退出: int tout = 3 * 60 * 1000; InternetSetOptionA( m_hSession, iInternet_Opti蓮花橋on_Connect_Timeout, (void *)&tout, sizeof(int) );。

InternetSetOptionA( m_hSession, iInternet_Option_Send_Timeout, (void *)&tout, sizeof(int) ); InternetSetOptionA( m_hSession, iInternet_Option_Receive_Timeout, (void *)&tout, sizeof(int) );

但是依然沒有解決問題所以只好設置了用多線程的方式解決,具體解決方式就是:用線程執(zhí)行下載網(wǎng)頁的操作,然后在每次下載好一個網(wǎng)頁后蓮花橋更新一下對應的時間,設置一個定時器,查詢該時間是否超過幾分鐘(比如超過7分鐘)那就說明InternetOpenUrl卡住了,使用以下代碼。

TerminateThread( m_h[a], 0 ); //中斷線程 ::WaitForSingleObject( m_h[a], iInfInite ); //等待線程結(jié)束先強行中斷線程,然后等待線程結(jié)束后,再重開一個線程

貼上代碼線程類:#define dShu 4class CXian{public:private: iHandle m_h[4]; iSystemTime m_tm;public: void Begin();

void Check();蓮花橋 void Tui();private:public: CXian(); ~CXian();};CXian::CXian(){ for(int a=0; a

}CXian::~CXian(){}iuint iStdCall Proc2( void *p ){ int zhi = (int)p; g_DoNr[zhi].Get( zhi ); return 1;

}void CXian::Begin(){ for(int a=0; a

}}void CXian::Check(){ ::GetLocalTime( &m_tm ); int c = 0; for(int a=0; a

if( c>7 ) {蓮花橋 TerminateThread( m_h[a], 0 ); //中斷線程 ::WaitForSingleObject( m_h[a], iInfInite ); //等待線程結(jié)束

//重啟線程 m_h[a] = CreateThread( inull, 0, Proc2, (void*)a, 0, inull ); } }}void CXian::Tui(){ for(int a=0; a

{ ::WaitForSingleObject( m_h[a], iInfInite ); } exit(0);}線程開始代碼: g_Xian.Begin(); SetTimer( g_hwnd, 1, 5 蓮花橋* 30 * 1000, TmProc ); //設置2.5分鐘一個定時器

定時器響應函數(shù)void iStdCall TmProc(iHWnd hwnd, iuint msg, iuint id, iuint dwTime){ PostMessage( g_hwnd ,dMyMsg1, 0, 0 );

}在消息響應中增加 case dMyMsg1: g_Xian.Check(); break;通過以上操作完美的解決了InternetOpenUrl卡住的問題

標簽列表