vbscript.dll have 3 tlbs.
That example:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>
#include "VBS_3.h"
void vMsgBox(TCHAR *szErr, int nErr)
{
}
int RegExpSearch( LPCTSTR szSearchPattern, LPCTSTR szTextForSearch, LPTSTR szOutBuf, int cbOutBuf, BOOL bReplace)
{
HRESULT hres;
static IRegExp * pRegExp = 0;
static IMatch * pIMatch = 0;
static IMatchCollection * pIMatchCollection = 0;
VARIANT_BOOL vbMatch = 0;
VARIANT_BOOL vbIgnoreCase = -1;
VARIANT_BOOL vbGlobal = -1;
// create the regex component
hres = CoCreateInstance( &CLSID_RegExp, NULL, CLSCTX_INPROC_SERVER, &IID_IRegExp, (LPVOID *)&pRegExp);
if (!SUCCEEDED(hres)) { // ?????? ???????? RegExp ??????????
//vMsgBox("RegExp not created!",0);
ERR: if (hres==REGDB_E_CLASSNOTREG ) vMsgBox("REGDB_E_CLASSNOTREG",0);
if (hres==CLASS_E_NOAGGREGATION ) vMsgBox("CLASS_E_NOAGGREGATION",0);
if (hres==E_NOINTERFACE ) vMsgBox("E_NOINTERFACE",0);
return -1;
}
hres = CoCreateInstance( &CLSID_MatchCollection, NULL, CLSCTX_INPROC_SERVER, &IID_IMatchCollection, (LPVOID *)&pIMatchCollection);
if (!SUCCEEDED(hres)) { goto ERR; }
//
//vMsgBox("RegExp created!",0);
//
//// set the regex pattern
//CComBSTR bstrPattern(_T("[\\S]+[.]tmp"));
//BSTR bszPat = _T("vi(.)o");
BSTR bszPat = SysAllocString(L"vi(.)o");
//BSTR bszSea = _T("oksdhfosjdfoisdjfpsfjdpsdfkptxest;?????i????esttt_vito_ttttttghjkhjkhjlhjkljklk\n");
BSTR bszSea = SysAllocString(L"oksdhfosjdfoisdjfpsfjdpsdfkptxest;?????i????esttt_vito_ttttttghjkhjkhjlhjkljklk\n");
hres = pRegExp->lpVtbl->put_Pattern(pRegExp,bszPat);
// pRegExp->lpVtbl->get_IgnoreCase(pRegExp,&vbIgnoreCase);
// pRegExp->lpVtbl->put_IgnoreCase(pRegExp,FALSE);
// pRegExp->lpVtbl->get_Global(pRegExp,&vbGlobal);
// pRegExp->lpVtbl->put_Global(pRegExp,vbGlobal);
hres = pRegExp->lpVtbl->Test(pRegExp,bszSea, (VARIANT_BOOL *)&vbMatch);
if (!SUCCEEDED(hres) || !vbMatch) {
vMsgBox("RegExp not found!",0);
}
SysFreeString(bszPat);
SysFreeString(bszSea);
//////////// ????? ??????
// ?????????? ??????????
if (pIMatchCollection) pIMatchCollection->lpVtbl->Release(pIMatchCollection);
if (pIMatch) pIMatch->lpVtbl->Release(pIMatch);
if (pRegExp) pRegExp->lpVtbl->Release(pRegExp);
return 1;
}