|
-
March 25th, 2003, 01:36 PM
#1
InternetQueryOption and InternetSetOption
I try to set internet option of
INTERNET_OPTION_RECEIVE_TIMEOUT by following code.
it return error code 12010.
I think that it maybe the handle is not the right type of handle .And try another handle return by InternetOpenUrl but failed also.
And I tried INTERNET_OPTION_CONNECT_TIMEOUT also but failed.
both handle is right.
thank you .
m_hSession = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
char szTimeout[10];
memset(szTimeout,0,10);
DWORD dwSize=10;
BOOL bSetInternetOption ;
bSetInternetOption = InternetQueryOption(m_hSession,INTERNET_OPTION_CONNECT_TIMEOUT ,szTimeout,&dwSize);
long lTimeout = atol(szTimeout);
memset(szTimeout,0,10);
memcpy(szTimeout,"3000",5);
bSetInternetOption = InternetSetOption(m_hSession,INTERNET_OPTION_CONNECT_TIMEOUT ,szTimeout,5);
strTimeout.Format("%d,%d,%x",bSetInternetOption,GetLastError(),GetLastError());
bSetInternetOption = InternetQueryOption(m_hSession,INTERNET_OPTION_CONNECT_TIMEOUT ,szTimeout,&dwSize);
lTimeout = atol(szTimeout);
-
March 25th, 2003, 02:55 PM
#2
Hi,
Code:
12010 ERROR_INTERNET_BAD_OPTION_LENGTH
The length of an option supplied to InternetQueryOption
or InternetSetOption is incorrect for the type of option specified.
Check your code again.
Regards,
Emanuel Vaduva
-
March 25th, 2003, 06:03 PM
#3
You need to call InternetQueryOption twice, the first time passing in a NULL pointer to find out how big a buffer the API needs, and the second time with a buffer of size returned by the first call. Since you're getting a 12010 error, your guess-timate of 10 for szTimeout must not be big enough. Try:
DWORD dwSize=0;
BOOL bSetInternetOption ;
bSetInternetOption = InternetQueryOption(m_hSession,INTERNET_OPTION_CON
NECT_TIMEOUT ,NULL,&dwSize);
char* szTimeout=new char[dwSize];
memset(szTimeout,0,dwSize);
bSetInternetOption = InternetQueryOption(m_hSession,INTERNET_OPTION_CON
NECT_TIMEOUT ,szTimeout,&dwSize);
long lTimeout = atol(szTimeout);
delete[] szTimeout;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|