[C#] 纯文本查看 复制代码
/// <summary>
/// 获取JS时间戳 13位
/// </summary>
/// <returns></returns>
public stringGetTimeByJs()
{
Type obj = Type.GetTypeFromProgID("ScriptControl");
if (obj == null)return null;
object ScriptControl = Activator.CreateInstance(obj);
obj.InvokeMember("Language",BindingFlags.SetProperty, null, ScriptControl, newobject[] { "JScript"});
string js = "functiontime(){return new Date().getTime()}";
obj.InvokeMember("AddCode",BindingFlags.InvokeMethod, null, ScriptControl, newobject[] { js });
return obj.InvokeMember("Eval", BindingFlags.InvokeMethod,null, ScriptControl, newobject[] { "time()"}).ToString();
}