- Option Explicit
- Dim oWS, oFSO, oExcel, s
-
- Set oWS = CreateObject("WScript.Shell")
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set oExcel = CreateObject("Excel.Application")
- oExcel.DisplayAlerts = False
-
- s = "HKEY_CURRENT_USER\Software\Microsoft\Office\$\Excel\Security\AccessVBOM"
- oWS.RegWrite Replace(s, "$", oExcel.Version), 1, "REG_DWORD"
-
- s = "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long"
-
- oExcel.Workbooks.Add.VBProject.VBComponents.Add(1).CodeModule.AddFromString s
-
- oWS.Run "%windir%\system32\calc.exe"
- MsgBox "下面查找新打开的标题栏:计算器", vbSystemModal
-
- s = oExcel.Run("FindWindow", vbNullString, "计算器")
- MsgBox "窗口句柄: " & s
-
- oExcel.Quit()
复制代码 这个怎么一直找不到窗口的 |