国产探花免费观看_亚洲丰满少妇自慰呻吟_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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 牡丹江市| 和顺县| 张北县| 凌海市| 海口市| 凤山市| 永平县| 瑞安市| 巴东县| 石屏县| 故城县| 灌阳县| 海城市| 武汉市| 张家界市| 蕲春县| 渑池县| 敖汉旗| 乌恰县| 玛多县| 桐梓县| 噶尔县| 镇江市| 久治县| 万荣县| 高台县| 平和县| 汶上县| 长垣县| 黑龙江省| 金堂县| 象州县| 佛山市| 富锦市| 彩票| 赣州市| 遵义市| 崇信县| 松阳县| 蒙阴县| 广南县|