Journal(2005) | Blog(2006) | RandomLink | WhoAmI | LiveBookmark | HomePage

<<Previous: RSS阅读设置  >>Next: ReferSite

Win32下的进程模块

Category: Modules   Keywords: Win32::Process

我的任务很简单,启动一个程序(c:\a.exe),然后过1分种终止进程,然后再启动,如此循环/loop.

Win32::Process我没用过,也是第一次用,其中什么子进程之类的也不太懂。详细的请查阅perldoc Win32::Process.
如下是我的代码,给需要完成相似任务的朋友做参考:

use Win32::Process;

while (1) {
    my ($ProcessObj, $exitcode);
    Win32::Process::Create($ProcessObj,
        "c:\\a.exe",
        "",
        0,
        NORMAL_PRIORITY_CLASS,
        ".")|| die ErrorReport();

    $ProcessObj->GetExitCode( $exitcode );
    sleep 60;
    my $pid = $ProcessObj->GetProcessID();
    Win32::Process::KillProcess($pid, $exitcode);
    sleep 1;
}

<<Previous: RSS阅读设置  >>Next: ReferSite

Options: +Del.icio.us

Related items Created on 2004-10-30 19:29:19, Last modified on 2004-11-11 00:27:57
Copyright 2004-2005 All Rights Reserved. Powered by Eplanet && Catalyst 5.62.