建立一个临时的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.
error C2065: 'T2BSTR' : undeclared identifier
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.
下面是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即可
你没有在看?
COleVariant varTemp("1234")
VariantCopy(PostData,&varTemp);
Navigate(...,"t1=a",...);然后在服务器端
response.write request("t1")
把a显示出来.望指教!!!
VariantCopy(PostData,&varTemp);
Navigate(...,PostData,...);
VariantCopy(PostData,&varTemp); <======这里出错,非法操作? pe->Navigate(URL,NULL,NULL,PostData,NULL);
你重新申明了一个和参数同名的变量,当然会出错了。
VariantCopy(PostData1,&varTemp); <=====同样的问题,还是非法操作?不明白?pe->Navigate(URL,NULL,NULL,PostData1,NULL);
没分配内存空间
VARIANT *PostData1=new VARIANT;