Steven,

This is how I do it by window-title to insure that only one instance of
a given program can run at a time. It might be adaptable for your
purposes:

    # Check for another instance of this program.
    use Win32::GUI;
    my $Desktop = GUI::GetDesktopWindow();
    my $Window  = GUI::GetWindow($Desktop, GW_CHILD);
    my $Nbr     = 0;

    while ($Window)
    {
        my $Title  = GUI::Text($Window);
        if (length($Title) > 1 and $Title !~ /command prompt/i) {$Nbr++
if ($Title =~ /^archivepdf/i)}
        $Window = GUI::GetWindow($Window, GW_HWNDNEXT);
    }

    if ($Nbr > 1)
    {
        print(STDERR "Another instance of this program exists, exiting
program\n");
        print(STDERR "Ending $0\n");
        exit(1);
    } 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Steven Satelle
Sent: Friday, April 08, 2005 09:42
To: perl-win32-admin@listserv.ActiveState.com
Subject: Win32::Process::Info

I'm trying to find the process id of a process on a win32 system (NT or
2k) 
I want to kill it, but all I have is the name - ActiveForms.

I've been messing about with Win32::Process::Info but while I can get
the process list, I cant get the process name or any info from it. Can
anyone tell me where I'm going wrong?

Heres a sample of the code:

use WIn32::Process::Info;

$processes = Win32::Process::Info->new();

@pids = $processes->ListPids();


foreach $pid (@pids)
{
        @info = $processes->GetProcInfo($pid);
        print @info{'CreationDate'}, "\n";
}
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to