利用mshtml在visual free basic里执行js.
#include once "Afx/CDispInvoke.inc" DIM pdom AS CDispInvoke = "HTMLFILE" IF pdom.DispPtr = NULL THEN END Else Print "成功运行" DIM oWin AS CDispInvoke = pdom.Invoke("parentWindow") IF oWin.DispPtr THEN oWin.Invoke("execScript","var a=1+2;var js={""姓名"":""刘德华"",""年龄"":59},nm=js[‘姓名‘];") Print owin.get("a") Print cwstr(owin.get("nm"),CP_UTF8) END IF
运行结果: