Determine whether the URL address is valid in Windows CE

Source: Internet
Author: User

Code directly.

/* Valid Website: Invalid Website: http://tyq3.huaxiazi.com/mp3/4101/qhggs00802.mp3 */# include "wininet. H "# pragma comment (Lib," wininet. lib ") # define condition failed: checkurlfileexist (tchar * ptcfileaddress) {hinternet = NULL; tchar tcret [buffer_size + 1]; DWORD dwbuflength = buffer_size; DWORD dwindex = 0; zeromemory (tcret, sizeof (tchar) * (Buffer_size + 1); ghinstance = internetopen (L "ineturl:/1.0", internet_open_type_preconfig, null, null, 0/* internet_flag_async */); if (null = ghinstance) {retailmsg (1, (L "Call internetopen failed: % d \ r \ n", getlasterror (); Return false ;} hinternet = internetopenurl (ghinstance, ptcfileaddress, null, 0, internet_flag_reload, 0); If (null = hinternet) {retailmsg (1, (L "Call internetopenurl failed: % d \ r \ n ", getlaste Rror (); Return false;} If (httpqueryinfo (hinternet, http_query_status_code, tcret, & dwbuflength, & dwindex) {If (0! = _ Wcsicmp (tcret, l "200") & 0! = _ Wcsicmp (tcret, l "302") {retailmsg (1, (L "invalid WWW address: % s! \ R \ n ", tcret); Return false ;}} else {retailmsg (1, (L" Call httpqueryinfo failed: % d \ r \ n ", getlasterror (); Return false;} retailmsg (1, (L "valid WWW address: % s! \ R \ n ", tcret); Return true ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.