国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

vc6.0調用vb腳本

2019-11-08 02:33:04
字體:
來源:轉載
供稿:網友
// testvb.cpp : Defines the entry point for the console application.//#import "msscrWord dwFilesize = 0; DWORD dwActSize =0; dwFilesize = GetFileSize(hFile, NULL); BYTE *pBytes = new BYTE[dwFilesize+1]; memset(pBytes, 0, dwFilesize+1); ReadFile(hFile, pBytes, dwFilesize, &dwActSize,NULL); CloseHandle(hFile); _bstr_t bstrScriptBody = (LPCTSTR)pBytes; _variant_t vtResult; int nTimeout = 30; IScriptControlPtr ptrScript; ptrScript.CreateInstance(__uuidof(ScriptControl)); ptrScript->Timeout = 1000 * nTimeout; //超時設置 ptrScript->PutAllowUI( VARIANT_TRUE ); ptrScript->PutLanguage( _bstr_t(_T("VBScript")) ); //HRESULT hr = ptrScript->ExecuteStatement(bstrScriptBody); // ptrScript->AddCode( _bstr_t("Function GetValue()/r/n MsgBox /"Hello world/" /r/n GetValue = 5 /r/n End Function/r/n")); ptrScript->AddCode(bstrScriptBody); vtResult = ptrScript->Eval(_bstr_t("GetValue")); // ptrScript->Run(_bstr_t("GetValue"), &vtResult); ptrScript.Release(); delete[] pBytes; long lRet = vtResult.iVal; cout << "VBScript:GetValue->returnValue = " << lRet << std::endl; cin.get(); } catch(_com_error &e) { _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); std::cout<<"VBS Script Engine"<<std::endl; std::cout<<"COM error occurred, source:"<<(LPCTSTR)bstrSource<<std::endl; std::cout<<"Description:"<<(LPCTSTR)bstrDescription<<std::endl; cin.get(); } CoUninitialize(); return 0;}

vbs腳本為

Function GetValue() MsgBox "Hello world" GetValue = 5 End Function
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 冷水江市| 莆田市| 宁河县| 老河口市| 邯郸县| 阳谷县| 柯坪县| 克什克腾旗| 娄底市| 大化| 朝阳县| 苍梧县| 特克斯县| 海门市| 柘荣县| 新田县| 乌鲁木齐县| 厦门市| 长葛市| 六盘水市| 行唐县| 滨海县| 晋州市| 岳西县| 汝南县| 通河县| 阿图什市| 启东市| 抚顺市| 当涂县| 赣州市| 公安县| 峡江县| 武乡县| 穆棱市| 富裕县| 绥芬河市| 潼南县| 乐亭县| 收藏| 长子县|