我用wininet库中的函数来定时下载一个网络上的网页,每分钟执行一次,刚开始一切正常,程序按照设计的功能实现了,现在出现一个问题,我是每当程序运行一段时间,大概是1天或者2天左右的时候,InterNetOpen函数就会返回NULL值,然后一直都是NULL值,如果关闭程序,再打开,又正常了。
用getlasterror返回0请问如何Debug呢?代码如下
      hInternet = InternetOpen("Application",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0) ;      if(!hInternet)
      {   ........
       continue;
       }

解决方案 »

  1.   

    After the calling application has finished using the HINTERNET handle returned by InternetOpen, it must be closed using the InternetCloseHandle function.
      

  2.   

    我的程序结构是这样的
    线程中:
    while(!stop)
    {
    internetopen()...
    internetopenurl....
    if(error) continue}      InternetCloseHandle(hOpenUrl) ;
          InternetCloseHandle(hInternet) ;是不是每次internetopen都必须对应一个interclosehandle呢?还是可以等程序结束的时候,在执行interclosehandle呢?
      

  3.   

    关于InternetOpen请参考
    http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx为什么将internetopen放到循环里面呢?