Click here to Skip to main content
15,889,992 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RightJustify a widechar string Pin
Chris Losinger13-Oct-10 1:31
professionalChris Losinger13-Oct-10 1:31 
GeneralRe: RightJustify a widechar string Pin
CPallini13-Oct-10 1:38
mveCPallini13-Oct-10 1:38 
AnswerRe: RightJustify a widechar string Pin
Cedric Moonen13-Oct-10 1:49
Cedric Moonen13-Oct-10 1:49 
QuestionProxy authentication failed error code is 407. Same code works fine without proxy. Pin
amar_mhetre13-Oct-10 0:49
amar_mhetre13-Oct-10 0:49 
AnswerRe: Proxy authentication failed error code is 407. Same code works fine without proxy. Pin
Rahul Vaishnav13-Oct-10 1:56
Rahul Vaishnav13-Oct-10 1:56 
GeneralRe: Proxy authentication failed error code is 407. Same code works fine without proxy. Pin
amar_mhetre13-Oct-10 2:06
amar_mhetre13-Oct-10 2:06 
GeneralRe: Proxy authentication failed error code is 407. Same code works fine without proxy. Pin
Rahul Vaishnav13-Oct-10 2:45
Rahul Vaishnav13-Oct-10 2:45 
GeneralRe: Proxy authentication failed error code is 407. Same code works fine without proxy. Pin
amar_mhetre13-Oct-10 2:56
amar_mhetre13-Oct-10 2:56 
Thanks for the links. I allready gone through the links and found solution.

It should as follows....

HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;WORD dwError, dwErrorCode;
hOpenHandle = InternetOpen(NULL,INTERNET_OPEN_TYPE_PROXY, _T("192.168.9.10:8080"), NULL, INTERNET_FLAG_SECURE);
// _T("192.168.9.10:8080") is proxy with port number
DWORD dwServiceType = AFX_INET_SERVICE_HTTP;
CString szServer, szObject;
INTERNET_PORT nPort;
AfxParseURL (strURL, dwServiceType, szServer, szObject, nPort);
// strURL is any URL whose data to retrieve say http://www.google.com
hConnectHandle = InternetConnect(hOpenHandle,szServer,INTERNET_INVALID_PORT_NUMBER,
_T("test1"), _T("test"), INTERNET_SERVICE_HTTP, 0, 0);
// _T("test1"), _T("test") is username and password for proxy at my server

hResourceHandle = HttpOpenRequest(hConnectHandle, _T("GET"), szObject, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);

resend:
HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);

DWORD dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);
HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER |
HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL);

dwErrorCode = hResourceHandle ? ERROR_SUCCESS : GetLastError();
dwError = InternetErrorDlg(this->GetSafeHwnd(), hResourceHandle, dwErrorCode,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA, NULL);

if (dwError == ERROR_INTERNET_FORCE_RETRY)
goto resend;

DWORD dwNumberOfBytesRead;
char sz[1024];
int result;
do
{
result = InternetReadFile(hResourceHandle, sz, 1023, &dwNumberOfBytesRead);
sz[dwNumberOfBytesRead] = '\0';
int x = strlen(sz);
strResult += sz;
memset(sz, 0, 1024);
} while(result && dwNumberOfBytesRead != 0);

return strResult;

I was trying/searching this for two days and finally this is done. For others who want proxy authentication, can refer this code. But still there has to be a way by using CInternetSession as it is wrapper to WinInet API's used above. I am happy now that code is working fine now.

Thanks once again for your help.
QuestionDebug assersion error Pin
MKC00213-Oct-10 0:33
MKC00213-Oct-10 0:33 
AnswerRe: Debug assersion error Pin
Niklas L13-Oct-10 0:35
Niklas L13-Oct-10 0:35 
GeneralRe: Debug assersion error Pin
MKC00215-Oct-10 2:37
MKC00215-Oct-10 2:37 
AnswerRe: Debug assersion error Pin
David Crow13-Oct-10 8:16
David Crow13-Oct-10 8:16 
GeneralRe: Debug assersion error Pin
MKC00215-Oct-10 2:40
MKC00215-Oct-10 2:40 
QuestionRe: Debug assersion error Pin
David Crow15-Oct-10 2:49
David Crow15-Oct-10 2:49 
AnswerRe: Debug assersion error Pin
MKC00216-Oct-10 3:11
MKC00216-Oct-10 3:11 
AnswerRe: Debug assersion error Pin
David Crow16-Oct-10 11:24
David Crow16-Oct-10 11:24 
GeneralRe: Debug assersion error [modified] Pin
MKC00217-Oct-10 18:49
MKC00217-Oct-10 18:49 
AnswerRe: Debug assersion error Pin
David Crow18-Oct-10 9:56
David Crow18-Oct-10 9:56 
QuestionFile creation date and time Pin
john563212-Oct-10 21:09
john563212-Oct-10 21:09 
AnswerRe: File creation date and time Pin
trotwa12-Oct-10 21:27
trotwa12-Oct-10 21:27 
GeneralRe: File creation date and time Pin
Richard MacCutchan12-Oct-10 22:39
mveRichard MacCutchan12-Oct-10 22:39 
AnswerRe: File creation date and time Pin
CPallini12-Oct-10 21:30
mveCPallini12-Oct-10 21:30 
GeneralRe: File creation date and time Pin
bleedingfingers12-Oct-10 21:55
bleedingfingers12-Oct-10 21:55 
GeneralRe: File creation date and time Pin
CPallini12-Oct-10 22:01
mveCPallini12-Oct-10 22:01 
AnswerRe: File creation date and time Pin
Sauro Viti12-Oct-10 21:32
professionalSauro Viti12-Oct-10 21:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.