Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by Mike Collins
Wed, 21 Feb 2007 18:26
WinInet, InternetOpen and Proxy settings...
Author: Mike Collins
Date: Wed, 21 Feb 2007 18:26
Date: Wed, 21 Feb 2007 18:26
39 lines
2217 bytes
2217 bytes
Hi all, just a quick question on using proxy settings with InternetOpen.
I have a live update system in place which works perfectly, however, some
customers have come back and requested the facility to input and use a proxy
server. Having looked at the MSDN reference it seemed pretty easy to
implement this within the initial InternetOpen call.
My code looks like this:
DWORD dwAccessType;
AnsiString szProxySz;
if (getProxyOptions())
{
dwAccessType = INTERNET_OPEN_TYPE_PROXY;
szProxySz = AnsiString("\"\"http=http://" + getProxyAddress() + ":" +
getProxyPortNum() + "\"\"");
}
else
{
dwAccessType = INTERNET_OPEN_TYPE_DIRECT;
szProxySz = NULL;
}
hINetHnd = InternetOpen(TEXT("Live Update"), dwAccessType,
szProxySz.c_str(), NULL, 0);
if (!hINetHnd)
throw EAbort(SysErrorMessage(GetLastError()), 0);
When no proxy setting are enabled, the code works without problem. When
they are enabled, with valid values, the InternetOpen call fails and
GetLastError returns, "Parameter are Incorrect"
Just a quick point before anyone suggests it, I can't use the preconfigured
proxy settings because of the context that my code is running in. Does
anyone have any ideas what I'm doing wrong here?
Many thanks in advance,
Mike C
Re: WinInet, InternetOpen and Proxy settings...
Author: Remy Lebeau (TeamB)
Date: Wed, 21 Feb 2007 23:13
Date: Wed, 21 Feb 2007 23:13
23 lines
1572 bytes
1572 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message
news:45dcb57a$1@newsgroups.borland.com...
> szProxySz = AnsiString("\"\"http=http://" + getProxyAddress()
+ ":" +
> getProxyPortNum() + "\"\"");
You have a lot of quotation marks in that string. Try removing them:
szProxySz = "http=http://" + getProxyAddress() + ":" +
getProxyPortNum();
> When no proxy setting are enabled, the code works without problem.
> When they are enabled, with valid values, the InternetOpen call
fails and
> GetLastError returns, "Parameter are Incorrect"
That is because you are specifying a malformed string value for the
proxy name.
Gambit
Re: WinInet, InternetOpen and Proxy settings...
Author: Mike Collins
Date: Thu, 22 Feb 2007 01:00
Date: Thu, 22 Feb 2007 01:00
57 lines
2947 bytes
2947 bytes
Hay Remy - that was simple :-)
Haven't had chance to test it fully as i'm at home at the minute (thus no
proxy) but the error message has gone - suggesting it works.
The only reason why i doubled up on the quotation marks is because of the
MSDN reference:
http://msdn2.microsoft.com/en-us/library/aa383996.aspx
[sic]
To list a proxy for a specific protocol, the string must follow the format
""<protocol><protocol>://<proxy_name>"". The valid protocols are HTTP,
HTTPS, FTP, and Gopher. For example, to list an FTP proxy, a valid string
would be ""ftp=ftp://ftp_proxy_name:21"", where ftp_proxy_name is the name
of the FTP proxy and 21 is the port number that must be used to access the
proxy. If the proxy uses the default port number for that protocol, the port
number can be omitted. If a proxy name is listed by itself, it is used as
the default proxy for any protocols that do not have a specific proxy
specified. For example, ""http=http://http_proxy other"" would use
http_proxy for any HTTP operations, while all other protocols would use
other.
- all the examples have double quote marks...
Thanks anyway,
Mike C
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:45dcd1f8$1@newsgroups.borland.com...
>
> "Mike Collins" <its@TheBottomOfThePost.com> wrote in message
> news:45dcb57a$1@newsgroups.borland.com...
>
>> szProxySz = AnsiString("\"\"http=http://" + getProxyAddress()
> + ":" +
>> getProxyPortNum() + "\"\"");
>
> You have a lot of quotation marks in that string. Try removing them:
>
> szProxySz = "http=http://" + getProxyAddress() + ":" +
> getProxyPortNum();
>
>> When no proxy setting are enabled, the code works without problem.
>> When they are enabled, with valid values, the InternetOpen call
> fails and
>> GetLastError returns, "Parameter are Incorrect"
>
> That is because you are specifying a malformed string value for the
> proxy name.
>
>
> Gambit
>
>
Re: WinInet, InternetOpen and Proxy settings...
Author: Remy Lebeau (TeamB)
Date: Thu, 22 Feb 2007 02:05
Date: Thu, 22 Feb 2007 02:05
14 lines
1449 bytes
1449 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message news:45dceaf4@newsgroups.borland.com... > The only reason why i doubled up on the quotation marks is because > of the MSDN reference: You can't always rely on MSDN's text at face value. MSDN tends to have typos, missing text, extra text, etc. in random places. Case in point, the same article you mentioned says that the <protocol> portion is doubled, which is not correct. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads