Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:38+00:00 2026-05-26T10:16:38+00:00

I’m trying to make an application compatible with the auto proxy API provided by

  • 0

I’m trying to make an application compatible with the auto proxy API provided by the WinINet library in order to make local pac files work, and am stuck with the error ERROR_CAN_NOT_COMPLETE when trying to call InternetGetProxyInfo…

I have been following the post of Eric Loewenthal (dev @Microsoft so I hope his suggestion are A-OK ;p) in here
and the idea should be:

  • Call the InternetInitializeAutoProxyDll function;
  • Call the InternetGetProxyInfo to get the proxy URL for each given requested URLs;
  • Call the InternetDeInitializeAutoProxyDll at the end.

Here is how my code looks like :

// Start by initializing the Auto proxy stuff
BOOL ok = InternetInitializeAutoProxyDll(0, pathToTheProxyPACFile, 
                                         NULL, NULL, NULL);
// Here ok is true so I consider the initialization was a success

// [...]

// Later on, I try to get the proxy used for each requested URL like this:
LPSTR proxyURL = NULL;
DWORD proxyURLLength = 0;
BOOL ok = InternetGetProxyInfo(requestedURL,
                               requestedURLLength,
                               hostName,
                               hostNameLength,
                              &proxyURL,
                              &proxyURLLength);
// Here ok is false, the proxy url and length are left as is, 
// and a call to GetLastError() returns 1003 :s

I can’t see what’s wrong with that, and couldn’t find any convincing example on the net (and the documentation is severely lacking…).

Please note I tried allocating a buffer for proxyURL and setting its size to proxyURLLength as the documentation isn’t clear about how the memory should be handled, but it doesn’t work and my understanding is that I should let WinINet handle it anyway, and use GlobalFree on proxyURL in case of success.

I have also tried using InternetCrackUrlA in order to get the host name just in case the class I use to get the host name from the requested URL was not ok with this API (and indeed, InternetCrackUrlA considers the port to be part of the host name…), but it didn’t help either.

Please let me know of any suggestion that might help me get this to work 😉

PS: I have been using WinHTTP to do the same thing in the same part of the code and it works correctly.
PPS: I am testing this on windows XP with IE8 installed.

Edit ==========> I have coded another program that only calls these functions, and in this case I don’t experience any problem, so I guess my problem comes not from the way I call InternetGetProxyInfo but from the state I’m in when I call it, that is within
an implementation of the event sink used for our embedded IE, unless there is a problem with my includes or something along those lines..?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:16:38+00:00Added an answer on May 26, 2026 at 10:16 am

    After making sure it works on a new project, I traced the cause of my problem and the call to get the proxy infos starts failing after a call to OleInitialize. Now, there was a comment about it in here, but I didn’t know what this guy was talking about (and God knows I wish I never knew) so it didn’t help me back then I first read it.

    In short, if you initialize COM with OleInitialize, you’ll have a “Single-Thread Apartment” thread and that implies InternetGetProxyInfo will fail with cryptic error ERROR_CAN_NOT_COMPLETE. The solution I used was to make another thread do the work.

    PS about the signature of InternetGetProxyInfo:

    • it seems the last two parameters should be set to NULL and 0 as I expected, and GlobalFree should be called on the string to free its memory if necessary.

    • the host name and host name length are optional.

    Thanks for your help 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.