[MFC] HttpOpenRequest 이용시 0xC0000005: 0xcccccccc 오류


HttpOpenRequest 이용시 디버깅 창에
"0xC0000005: 0xcccccccc 위치를 읽는 동안 액세스 위반이 발생했습니다."
메세지가 출력되어 무시하다 해결방법을 찾았습니다.

LPCTSTR szAcceptType = "*/*";
LPCTSTR szAccept = __ACE_HTTP_ACCEPT;
LPCTSTR szContentType= _T("Content-Type: application/x-www-form-urlencoded\r\n"); 
DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_FORMS_SUBMIT;
DWORD_PTR dwContext = NULL;

m_hReq =::HttpOpenRequest(m_hHttp, "POST", szURI, HTTP_VERSION, NULL, &szAcceptType, dwFlags, dwContext);
if(!m_hReq){
 return FALSE;
}

오류 해결방법

MSDN 함수 설명
HINTERNET HttpOpenRequest(
__in HINTERNET hConnect,
__in LPCTSTR lpszVerb,
__in LPCTSTR lpszObjectName,
__in LPCTSTR lpszVersion,
__in LPCTSTR lpszReferer,
__in LPCTSTR* lplpszAcceptTypes,
__in DWORD dwFlags,
__in DWORD_PTR dwContext
);

lplpszAcceptTypes 값을 다음과 같이 수정하면 됩니다.

LPCTSTR szAcceptType[]= {"*/*", NULL};
LPCTSTR szAccept = __ACE_HTTP_ACCEPT;
LPCTSTR szContentType = _T("Content-Type: application/x-www-form-urlencoded\r\n"); 
DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_FORMS_SUBMIT;
DWORD_PTR dwContext = NULL;

m_hReq =::HttpOpenRequest(m_hHttp, "POST", szURI, HTTP_VERSION, NULL, szAcceptType, dwFlags, dwContext);
if(!m_hReq){
 return FALSE;
}

"프로그래밍 / Visual C" 분류의 다른 글

[MFC] modal dialog(모달 대화상자) 숨긴채로 시작하기 (0)2014/03/04
[MFC] 프로세스 파일 경로 (0)2013/09/24
[MFC] OpenSSL Visual Studio 2008에서 컴파일 및 설치 하기 (0)2009/05/11
[MFC] Visual Studio 2008에서 zlib 1.2.3 컴파일 (0)2009/04/21
IE8설치후 VS2008 스크립트 오류 문제 (4)2009/03/31
데이크스트라 알고리즘(Dijkstra algorithm) (2)2008/12/29
Microsoft Office 2007 연동 (1)2008/06/04
GDI+에서 Round Rectangle 그리기. (0)2008/03/14
VC macro __FUNCTION__ UNICODE에서 사용하기 (0)2008/03/14
MulDiv (0)2007/12/12


Powered by Textcube