考虑到大家对可执行程序的担心,这里贴出VB全部代码 大家如果有VB的基础,可以自行编译
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Form_Load() Dim Pos, hFmWnd As Long, sScript As String, sFunName As String, sVar As String, sRet As String Dim FScript As MSScriptControl.ScriptControl If Len(Command) < 5 Then End '第一行为函数名称,第二行为函数参数,其余为内容 sScript = Command Pos = InStr(1, sScript, "{", vbTextCompare) If Pos Then sScript = Mid$(sScript, Pos + 1, Len(sScript)) End If Pos = InStr(1, sScript, "}", vbTextCompare) If Pos Then sScript = Mid$(sScript, 1, Pos - 1) End If sScript = Replace(sScript, Chr(1), vbCrLf) Pos = InStr(1, sScript, vbCrLf) sFunName = Mid$(sScript, 1, Pos - 1) sScript = Mid$(sScript, Pos + 1, Len(sScript)) Pos = InStr(1, sScript, vbCrLf) sVar = Mid$(sScript, 1, Pos - 1) sScript = Mid$(sScript, Pos + 1, Len(sScript)) If InStr(1, sVar, "Debug", vbTextCompare) Then MsgBox "执行函数名称:" & sFunName MsgBox "参数:" & sVar MsgBox "脚本内容:" & sScript End If Set FScript = New MSScriptControl.ScriptControl FScript.Language = "VBScript" FScript.AddCode sScript FScript.Timeout = -1 sRet = FScript.Run(sFunName, sVar) If InStr(1, sVar, "Debug", vbTextCompare) Then MsgBox "返回值" & sRet End If hFmWnd = FindWindow("TMRunForm", "wxScript")
Call SetWindowText(hFmWnd, sRet) End End Sub
|