title: InternetQueryOption crashes on Windows XP
body: <p>The following code is more or less just copied from MSDN documentation. On Windows Vista and Windows 7 it works fine, but in crashes on XP with an access violation int the call to <code>InternetQueryOption</code>.
  Anyone got an idea what the problem could be?</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
  
    HINTERNET hInternet = InternetOpen("x", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    //
    // 1. Set
    //
    {
      INTERNET_PER_CONN_OPTION_LIST    List;
      INTERNET_PER_CONN_OPTION         Option[2];
      unsigned long                    nSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
  
      Option[0].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
      Option[0].Value.pszValue = "http://myserver/get_proxy_info.dll";
      Option[1].dwOption = INTERNET_PER_CONN_FLAGS;
      Option[1].Value.dwValue = PROXY_TYPE_AUTO_PROXY_URL;
  
      List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
      List.pszConnection = NULL;
      List.dwOptionCount = 2;
      List.dwOptionError = 0;
      List.pOptions = Option;
  
      if(!InternetSetOption(hInternet, INTERNET_OPTION_PER_CONNECTION_OPTION, &amp;List, nSize))
         printf("InternetQueryOption failed! (%d)\n", GetLastError());
    }
    //
    // 2. Query
    //
    {
      INTERNET_PER_CONN_OPTION_LIST    List;
      INTERNET_PER_CONN_OPTION         Option[5];
      unsigned long                    nSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
  
      Option[0].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
      Option[1].dwOption = INTERNET_PER_CONN_AUTODISCOVERY_FLAGS;
      Option[2].dwOption = INTERNET_PER_CONN_FLAGS;
      Option[3].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
      Option[4].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
  
      List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
      List.pszConnection = NULL;
      List.dwOptionCount = 5;
      List.dwOptionError = 0;
      List.pOptions = Option;
  
      printf("InternetQueryOption:\n");
      if(!InternetQueryOption(hInternet, INTERNET_OPTION_PER_CONNECTION_OPTION, &amp;List, &amp;nSize))
         printf("InternetQueryOption failed! (%d)\n", GetLastError());
         if(Option[0].Value.pszValue != NULL)
         printf("%s\n", Option[0].Value.pszValue);
  
      if((Option[2].Value.dwValue &amp; PROXY_TYPE_AUTO_PROXY_URL) == PROXY_TYPE_AUTO_PROXY_URL)
        printf("PROXY_TYPE_AUTO_PROXY_URL\n");
  
      if((Option[2].Value.dwValue &amp; PROXY_TYPE_AUTO_DETECT) == PROXY_TYPE_AUTO_DETECT)
         printf("PROXY_TYPE_AUTO_DETECT\n");
  
      INTERNET_VERSION_INFO      Version;
      nSize = sizeof(INTERNET_VERSION_INFO);
  
      InternetQueryOption(hInternet, INTERNET_OPTION_VERSION, &amp;Version, &amp;nSize);
  
      if(Option[0].Value.pszValue != NULL)
         GlobalFree(Option[0].Value.pszValue);
  
      if(Option[3].Value.pszValue != NULL)
         GlobalFree(Option[3].Value.pszValue);
  
      if(Option[4].Value.pszValue != NULL)
         GlobalFree(Option[4].Value.pszValue);
  
    }
  
  }
  </code></pre>
  
  <p>In Windows XP, it hits memory access violation trying to access something behind <code>NULL</code> pointer.</p>
  
  <pre><code>    wininet.dll!PROXY_SERVER_LIST::CopyString(void) Unknown
      wininet.dll!PROXY_INFO::GetProxySettings(struct INTERNET_PROXY_INFO_EX *,int)   Unknown
      wininet.dll!PROXY_INFO_GLOBAL::GetProxySettings(struct INTERNET_PROXY_INFO_EX *,int)    Unknown
      wininet.dll!QueryPerConnOptions(void *,int,struct INTERNET_PER_CONN_OPTION_LISTA *) Unknown
      wininet.dll!_InternetQueryOptionA@16()  Unknown
  &gt;   InternetQueryOption.exe!main(int argc=1, char * * argv=0x003e2e60) Line 55  C++
      InternetQueryOption.exe!__tmainCRTStartup() Line 278    C
  </code></pre>