|
Example Program #06
This program illustrates the eValid EPI interface putElementProperty
command that puts values into the DOM using the eValid browser.
The example program is set up as a to accept these arguments:
The program invocation would be as follows: example06.exe URL IDX NAME VALUE
For example, a run.bat containing something like:
Program Source
Here is the CPP for the EPI program for this requirement.
#include "epi.h"
using namespace std;
int main(int argc, TCHAR* argv[], TCHAR* envp[])
{
if (argc < 5)
{
cout << "Syntax: example06.exe \"url\" idx \"name\" \"value\"" << endl;
return 1;
}
LPCTSTR lpszUrl = argv[1];
long index = _tstol(argv[2]);
LPCTSTR lpszName = argv[3];
LPCTSTR lpszValue = argv[4];
::CoInitialize(NULL);
IEvalid * pEvalid = NULL;
HRESULT hr = CoCreateInstance(CLSID_Evalid, NULL,
CLSCTX_INPROC_SERVER, IID_IEvalid, (void**)&pEvalid);
if (SUCCEEDED(hr))
{
pEvalid->InitLink(CComBSTR(lpszUrl));
long numItems;
if( SUCCEEDED(pEvalid->get_NumElements(0, NULL, &numItems)))
{
if (index < 0 || index >= numItems)
cout << "index is out of bounds" << endl;
else
pEvalid->put_ElementAttribute(0, index,
CComBSTR(lpszName), CComBSTR(lpszValue), NULL);
}
pEvalid->Release();
}
else
if (hr == E_ACCESSDENIED)
cout << "Missing a valid EPI license key!" << endl;
else
cout << "Unable to load EPI!" << endl;
::CoUninitialize();
return 0;
} |
Resources