1、点击开始-运行,输入oleview.exe或从vs2003打开工具-OLE/COM 对象查看器
2、使用该工具导出Micrisoft VBScript RegluarExpression为vbscript.idl
4、midl vbscript.idl生成vbscript.tlb,很可能会拷到VC目录下,如D:\Program Files\Microsoft Visual Studio 8\VC
#import "D:\Program Files\Microsoft Visual Studio 8\VC\vbscript.tlb" no_namespace
CoInitialize(NULL);
{
IRegExpPtr regExpPtr(__uuidof(RegExp));
regExpPtr->PutGlobal(VARIANT_TRUE);
regExpPtr->PutPattern("(\\d+\\.?\\d*|\\.\\d+)");
LPCTSTR testStr = "This 1dd2d";
IMatchCollectionPtr matches = regExpPtr->Execute(testStr); //用指针要出错
int count = matches->GetCount(); //count=0 判断 matches 应该是正确的
for (int i = 0; i < count; i++)
{
IMatchPtr match = matches->GetItem((long)i);
if(match)
printf("%s\n", (LPCTSTR)match->GetValue());
}
}
CoUninitialize();