Leser: 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use strict; use Win32; use Win32::Process; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } my $ProcessObj; Win32::Process::Create($ProcessObj, $ENV{SystemRoot}."\\explorer.exe", "explorer.exe D:\\", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); sleep 5; $ProcessObj->Kill(0);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use strict; use Win32; use Win32::Process; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } my $ProcessObj1; my $ProcessObj2; Win32::Process::Create($ProcessObj1, $ENV{SystemRoot}."\\explorer.exe", "explorer.exe D:\\", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); Win32::Process::Create($ProcessObj2, $ENV{SystemRoot}."\\notepad.exe", "notepad.exe C:\\test.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); sleep 5; $ProcessObj1->Kill(0) or &ErrorReport; $ProcessObj2->Kill(0) or &ErrorReport; sleep 1; my $pid = $ProcessObj1->GetProcessID(); system('taskkill','/PID',$pid); print "pid:$pid\n";
1 2 3 4 5 6
use Win32::API; use Win32::GUI qw { WM_CLOSE }; my $findwindow = new Win32::API("user32", "FindWindowA", ['P','P'], 'N'); my $hwnd = $findwindow->Call('Explorer', 0); Win32::GUI::SendMessage($hwnd, WM_CLOSE, 0, 0);
2010-12-03T09:49:54 GwenDragonWarum sendest du nicht einfach eine Windowmessage WM_CLOSE an das Explorer-Fenster
2010-12-03T10:05:13 Molaf(weil Explorer eben auch Systemprozess ist)?!