PostData->bstrVal = T2BSTR("T1=a&T2=b");

解决方案 »

  1.   

    why?
    error C2065: 'T2BSTR' : undeclared identifier
      

  2.   

    #include "atlbase.h"or #include "atlconv.h"
      

  3.   

    建立一个临时的COleVariant对象保存字符串,然后复制它的值到需要的位置。
    VariantCopy
    This function frees the destination variant and makes a copy of the source variant. HRESULT VariantCopy( 
    VARIANTARG FAR *pvargDest, 
    VARIANTARG FAR *pvargSrc ); 
    Parameters
    pvargDest 
    Pointer to the VARIANTARG to receive the copy. 
    pvargSrc 
    Pointer to the VARIANTARG to be copied. 
    Return Values
    One of the values obtained from the returned HRESULT and described in the following table is returned.
    Value Description 
    S_OK Success. 
    DISP_E_ARRAYISLOCKED The variant contains an array that is locked. 
    DISP_E_BADVARTYPE The source and destination have an invalid variant type (usually uninitialized). 
    E_OUTOFMEMORY Memory could not be allocated for the copy. 
    E_INVALIDARG One of the arguments is invalid. Res
    Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application. First, free any memory that is owned by pvargDest, such as VariantClear (pvargDest must point to a valid initialized variant, and not simply to an uninitialized memory location). Then pvargDest receives an exact copy of the contents of pvargSrc. If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrc is a VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or VT_UNKNOWN, AddRef is called to increment the object’s reference count.
      

  4.   

    简单点,就是怎样把要Post的数据如"t1=a&t2=b",放在Navigate(...VARIANT FAR* PostData,...)方法中???
      

  5.   

    在OnBeforeNavigate2函数中是无法修改Post数据的,只能在Navigate2中赋值
    下面是Navigate2函数的定义
    void Navigate2( LPCTSTR lpszURL, DWORD dwFlags = 0, LPCTSTR lpszTargetFrameName = NULL, LPCTSTR lpszHeaders = NULL, LPVOID lpvPostData = NULL, DWORD dwPostDataLen = 0 );你只要将t1=a&t2=b赋给lpvPostData ,并将字符串长度赋给dwPostDataLen 即可。
    如果你的服务器端的检查不严格的话,可以将url+"?"+"t1=a&t2=b"直接赋给lpszURL即可
      

  6.   

    倒~
    你没有在看?
    COleVariant varTemp("1234")
    VariantCopy(PostData,&varTemp);
      

  7.   

    我的想法就是
    Navigate(...,"t1=a",...);然后在服务器端
    response.write request("t1")
    把a显示出来.望指教!!!
      

  8.   

    ……COleVariant varTemp("t1=a")
    VariantCopy(PostData,&varTemp); 
    Navigate(...,PostData,...);
      

  9.   

    VARIANT *PostData; COleVariant varTemp("t1=a");
    VariantCopy(PostData,&varTemp);    <======这里出错,非法操作? pe->Navigate(URL,NULL,NULL,PostData,NULL);
      

  10.   

    在OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)函数中VARIANT *PostData;??
    你重新申明了一个和参数同名的变量,当然会出错了。
      

  11.   

    VARIANT *PostData1;COleVariant varTemp("t1=a");
    VariantCopy(PostData1,&varTemp); <=====同样的问题,还是非法操作?不明白?pe->Navigate(URL,NULL,NULL,PostData1,NULL);
      

  12.   

    笨笨,
    没分配内存空间
    VARIANT *PostData1=new VARIANT;
      

  13.   

    倒~把VARIANT *PostData;这一句删掉!