永久在线亚洲观看|亚洲日韩久久AV无码|亚洲无码视频在线免费看|欧美亚洲一区二区三区视频|人人澡人人澡人人看添AV|动漫精品视频一区二区三区|亚洲国产另类久久久精品极度|极品美女熟妇又黄又爽视频一区

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

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

1.長(zhǎng)沙市中院法官名冊(cè)

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

2.長(zhǎng)沙市中級(jí)人民法院法官名冊(cè)

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.長(zhǎng)沙市中級(jí)人民法院領(lǐng)導(dǎo)排名

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

4.長(zhǎng)沙中院?jiǎn)T額法官名單

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

5.長(zhǎng)沙市中級(jí)人民法院政治處

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

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

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

7.現(xiàn)任長(zhǎng)沙中級(jí)法院領(lǐng)導(dǎo)名單

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

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

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

9.長(zhǎng)沙市中級(jí)蓮花橋人民法院政治處電話

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

10.長(zhǎng)沙市中級(jí)法院領(lǐng)導(dǎo)名單

~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ù)庫(kù)中讀取網(wǎng)頁(yè) 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. 當(dāng)前的 Internet 會(huì)話句柄。

句柄必須由前期的 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. 一個(gè)空字符結(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.) 一個(gè)空字符結(jié)束的字符串變量的指針,指定發(fā)送到HTTP服務(wù)器的頭信息。

欲了解更多信息,請(qǐng)參閱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. 一個(gè)指向一個(gè)應(yīng)用程序定義的值,將隨著返回的句柄,一起傳遞給回調(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的連接,返回一個(gè)有效的句柄,如果連接失敗返回NULL。

要檢索特定的錯(cuò)誤訊息,請(qǐng)GetLastError 要確定為什么對(duì)服務(wù)器的訪問被拒絕,請(qǐng)調(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)址包含一個(gè)相對(duì)URL和一個(gè)空格分隔的基礎(chǔ)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.這是一個(gè)通用的函數(shù),可用于使用任何WinINet支持的協(xié)議檢索數(shù)據(jù)。

這個(gè)函數(shù)在應(yīng)用程序并不需要指定特定的協(xié)議,只需要相應(yīng)的URL的數(shù)據(jù)時(shí),特別有用InternetOpenUr蓮花橋l函數(shù)解析URL字符串,建立連接到服務(wù)器,并準(zhǔn)備下載的指定URL的數(shù)據(jù)該應(yīng)用程序可以用InternetReadFile (對(duì)文件)或InternetFindNextFile (對(duì)目錄)來檢索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——標(biāo)準(zhǔn)的Gopher端口和105——通常用于中央服務(wù)組織(民間組織)的名字搜索

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)閉它。

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

好像沒有對(duì)解決這個(gè)問題有幫助的信息為了解決InternetOpenUrl卡住的問題,嘗試了設(shè)置超時(shí)退出: 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) );

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

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

貼上代碼線程類:#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 ); //設(shè)置2.5分鐘一個(gè)定時(shí)器

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

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

標(biāo)簽列表