문제

I have an MFC application with CWebBrowser embedded. I wanna post data when navigating to the specified web . With some investigation around internet, I get to know one argument of the Navigate method aims to pass it. But I try it out several times and always fail. The post data is not carried in the data traffic(Yes. I capture the data and check it) after navigate method is invoked. I also check the post parameter of the before2Navigate calback and it's empty ..

Here is my snippet .

void PostData(LPCTSTR URL , LPCTSTR pPostData = NULL ) {
        _variant_t  flags(0L,VT_I4);
        _variant_t  target_frame_name("");
        _variant_t  post_data(!pPostData  ? _T("") : pPostData) ;  

        _variant_t  headers("Content-Type: application/x-www-form-urlencoded\r\n") ;
        this->Navigate(URL ,&flags,
            &target_frame_name,
            &post_data,
            &headers) ;     
    }

Please help me out . Thanks a lot.

도움이 되었습니까?

해결책

I have found out the reason, that's caused by the incorrect type of PostData. Construction of PostData ,as mentioned in my code, makes VT_BSTR VARIANT while the correct one is VT_ARRAY | VT_UI1

Here is the link for your reference hope it's helpful to you.

http://support.microsoft.com/default.aspx?scid=KB;en-us;q167658

One thing needs to be noted that the example of VS might has an defect and can not be used in unicode

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top