Macro/投稿/188 の変更点

http://sakura.qp.land.to/?Macro%2F%C5%EA%B9%C6%2F188


Top > Macro > 投稿 > 188

* WSH用sleep関数 [#uabb5e08]
-ページ: [[Macro/投稿]]
-作者: [[maru]]
-カテゴリー: vbs
-投稿日: 2008-03-29 (土) 16:50:13

** メッセージ [#la1ef4a2]
WScript.Sleepの代替です.~
WMIを経由するため,1回の呼出し毎に遅延が発生します.~
私の手元の環境では1回当たり35ミリ秒程度でした.

#code(vbscript){{
Private Sub Sleep(mSec)
On Error Resume Next
    GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery _
      ("select * from __instancecreationevent within 1" _
      & " where targetinstance isa 'Win32_Process'" _
      & " and targetinstance.ProcessID=0").NextEvent mSec
On Error GoTo 0
End Sub
}}

元ねたはhttp://www.vector.co.jp/soft/winnt/prog/se427882.htmlですが,Win32_NTLogEventはタイムアウトしない可能性があるので,ちょっと修正しました.

----
- 2.0.3.0以降で[Sleep関数>http://sakura-editor.sourceforge.net/htmlhelp2/HLP000268.html#Sleep]が使えるようになりました。 --  &new{2013-05-21 (火) 17:45:17};
- 2.0.3.0以降で[[Sleep関数>http://sakura-editor.sourceforge.net/htmlhelp2/HLP000268.html#Sleep]]が使えるようになりました。 --  &new{2013-05-21 (火) 17:45:17};

#comment

    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS