看了一下,东西不全,作不下去了.比如:IntPtr hOpen=InternetOpen(null, INTERNET_OPEN_TYPE_PRECONFIG,null, null,0);//初始化
Hope it helps a little.
----------------------------------------
To teach a fish how to swim.

解决方案 »

  1.   

    谢谢,你是说IntPtr hOpen=InternetOpen(null, INTERNET_OPEN_TYPE_PRECONFIG,null, null,0)中有些参数不全是导致InternetSetOption()用不起来的原因?
      

  2.   

    不是,我是说没有那一句,我这句没法调试:
    bool setOpt=InternetSetOption(hOpen,INTERNET_OPTION_DATA_SEND_TIMEOUT|INTERNET_OPTION_DATA_RECEIVE_TIMEOUT|INTERNET_OPTION_CONNECT_TIMEOUT,opByte,opBytes);
      

  3.   

    谢谢你帮助
    [DllImport("WinINet.dll")]
    static extern IntPtr InternetOpen(string a,long b,string c,string d, long e);InternetOpen
    HINTERNET InternetOpen(
        IN LPCTSTR lpszAgent,
        IN DWORD dwAccessType,
        IN LPCTSTR lpszProxyName OPTIONAL,
        IN LPCSTR lpszProxyBypass OPTIONAL,
        IN DWORD dwFlags
    );Initializes an application's use of the Win32 Internet functions. Returns a valid handle that the application passes on to subsequent Win32 Internet functions. If InternetOpen fails, it returns NULL. To get a specific error code, call GetLastError. 
    lpszAgent 
    Address of a string that contains the name of the application or entity calling the Internet functions (for example, Microsoft Internet Explorer). This name is used as the user agent in the HTTP protocol. 
    dwAccessType 
    Type of access required. Can be one of these values: 
    INTERNET_OPEN_TYPE_DIRECT 
    Resolve all host names locally. 
    INTERNET_OPEN_TYPE_PROXY 
    Pass requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this case, the function proceeds as for INTERNET_OPEN_TYPE_DIRECT. 
    INTERNET_OPEN_TYPE_PRECONFIG 
    Retrieve the proxy or direct configuration from the registry. 
    lpszProxyName 
    Address of a string that contains the name of the proxy server (or servers) to use if proxy access was specified. If this parameter is NULL, the function reads proxy information from the registry. For more information about this parameter, see the comments below. 
    lpszProxyBypass 
    Address of an optional list of host names or IP addresses, or both, that are known locally. Requests to these names are not routed through the proxy. The list can contain wildcards, such as "157.55.* *int*", meaning any IP address starting with 157.55, or any name containing the substring "int", will bypass the proxy. 
    If this parameter specifies the "<local>" macro as the only entry, the function bypasses any host name that does not contain a period. For example, "www.microsoft.com" would be routed to the proxy, whereas "internet" would not. If this parameter is NULL, the function reads the bypass list from the registry. dwFlags 
    Flag that indicates various options affecting the behavior of the function. Can be a combination of these values: 
    INTERNET_FLAG_OFFLINE 
    Satisfy download operations on this handle through the persistent cache only. If the item does not exist in the cache, the function returns an appropriate error code. 
    INTERNET_FLAG_ASYNC 
    Future operations on this handle may fail with ERROR_IO_PENDING. A status callback will be made with INTERNET_STATUS_REQUEST_COMPLETE. This callback will be on a thread other than the one for the original request. A status callback routine must be registered or the functions will be completed synchronously. 
    This function is the first Win32 Internet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application. When the application finishes using the Internet functions, it should call InternetCloseHandle to free the handle and any associated resources. If dwFlags includes INTERNET_FLAG_ASYNC, all handles derived from this handle will have asynchronous behavior as long as a status callback routine is registered. For a function to be completed synchronously, dwContext must be set to zero for that call. By default, the function assumes that the proxy specified by lpszProxyName is a CERN proxy. For example, "proxy" defaults to a CERN proxy called "proxy" that listens at port 80 (decimal). An application can specify more than one proxy, including different proxies for the different protocols. For example, if you specify "ftp=ftp://ftp-gw gopher=http://jericho:99 proxy", FTP requests are made through the FTP proxy "ftp-gw", which listens at port 21 (default for FTP), and Gopher requests are made through a CERN proxy called "jericho", which listens at port 99. All other requests (for example, HTTP requests) are made through the CERN proxy called "proxy", which listens at port 80. Note that if the application is only using FTP, for example, it would not need to specify "ftp=ftp://ftp-gw:21". It could specify just "ftp-gw". An application must specify the protocol names only if it will be using more than one protocol per handle returned by InternetOpen. The application can make any number of calls to InternetOpen, although a single call is normally sufficient. The application may need to have separate behaviors defined for each InternetOpen instance, such as different proxy servers configured for each. 
      

  4.   

    谢谢你一下就贴这么多.这些东西MSDN上我可以找到. IntPtr hOpen=InternetOpen(null, INTERNET_OPEN_TYPE_PRECONFIG,null, null,0);//初始化能不能告诉我 INTERNET_OPEN_TYPE_PRECONFIG=??????
      

  5.   

    不好意思,我居然这么粗心,把它落了。INTERNET_OPEN_TYPE_PRECONFIG=0