CPP > Win32 > WinINet(HTTP)

Redjini WiKi
< cpp‎ | win32


다음과 같이 이용할 경우

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;
}