天空是藍(lán)色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標(biāo)文件 #gcc helloworld.o -o helloworld //編譯成可執(zhí)行exe #helloworld //運(yùn)行exe
          數(shù)據(jù)加載中……
          [函數(shù)]function CheckUrl(url: string): Boolean; //檢查一個(gè)URL是否有效函數(shù)
          //檢查一個(gè)URL是否有效函數(shù)

          //可用來檢測網(wǎng)絡(luò)連接是否正確,InternetCheckConnection函數(shù)檢查不準(zhǔn)確,有些情況無法檢測到,而以下CheckUrl函數(shù)則不會(huì)。
          //uses wininet;
          function CheckUrl(url: string): Boolean; 
          var
            hSession, hfile, hRequest: hInternet;
            dwindex, dwcodelen: dword;
            dwcode: array[
          1..20] of Char;
            res: PChar;
          begin
            Result :
          = false;
            
          if Pos('http://', LowerCase(url)) = 0 then  url := 'http://' + url;
            hSession :
          = InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG,
              nil, nil, 0);
            
          if Assigned(hsession) then
            begin
              hfile :
          = InternetOpenUrl(hsession, PChar(url), nil, 0, INTERNET_FLAG_RELOAD, 0);
              dwIndex :
          = 0;
              dwCodeLen :
          = 10;
              HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex);
              res :
          = PChar(@dwcode);
              Result :
          = (res = '200'or (res = '302'); //200,302未重定位標(biāo)志
              
          if Assigned(hfile) then
                InternetCloseHandle(hfile);
              InternetCloseHandle(hsession);
            end;
          end;


          作者Blog:http://blog.csdn.net/siow/

          posted on 2005-11-29 10:35 bluesky 閱讀(693) 評論(0)  編輯  收藏 所屬分類: 記事本

          主站蜘蛛池模板: 托克托县| 融水| 图们市| 乳山市| 扎赉特旗| 霍城县| 黄山市| 贵港市| 榆社县| 新乡县| 博白县| 普格县| 萨嘎县| 贵港市| 山东省| 浦江县| 稷山县| 宽城| 青铜峡市| 房产| 蒲江县| 张家港市| 四平市| 吴旗县| 政和县| 方正县| 祥云县| 梨树县| 汉源县| 桐城市| 墨竹工卡县| 尼勒克县| 望江县| 株洲县| 澳门| 十堰市| 南乐县| 保靖县| 隆德县| 琼结县| 同心县|