| |
| INT AddField( |
| |
LPCTSTR lpszFieldName, |
|
| |
LPVOID lpFieldData, |
|
| |
DWORD cbFieldData |
|
| ); |
| INT AddField( |
| |
LPCTSTR lpszFieldName, |
|
| |
LPCTSTR lpszFieldData |
|
| ); |
The AddField method adds a new field to the current
form.
Parameters
- lpszFieldName
- A null-terminated string which specifies the name
of the field to add to the form. If this parameter is NULL or
points to an empty string, then a default field name will be
assigned.
- lpFieldData
- The form field data. Typically this will either by
a pointer to an array of bytes or a string which
specifies the value for the form field. If no data is to be
associated with the form field, then this argument may be
NULL.
- cbFieldData
- An unsigned integer value which specifies the number of bytes
of data in the form field. If this value is 0xFFFFFFFF (-1) then it
is assumed that the lpFieldData parameter is a pointer to a
null-terminated string. If lpFieldData is NULL, this value
must be zero.
Return Value
If the method succeeds, the return value is zero. If the method
fails, the return value is HTTP_ERROR. To get extended error
information, call GetLastError.
Remarks
The AddField method is used to add a field and its
associated value to a form created using the CreateForm
method. If the field name has already been added to the form, the
previous value is deleted and replaced by the new value.
If the Unicode version of this method is called and the
cbFieldData parameter is -1, the lpFieldData parameter
must point to a wide string terminated with a null character. The
string will be automatically converted to UTF-8 when the form data is
submitted to the server.
Example
CString strResult;
INT nResult = 0;
pClient->CreateForm(_T("/login.php"), HTTP_METHOD_POST, HTTP_FORM_ENCODED);
pClient->AddField(_T("UserName"), lpszUserName);
pClient->AddField(_T("Password"), lpszPassword);
nResult = pClient->SubmitForm(strResult);
pClient->DestroyForm();
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|