simxinzi 发表于 2010-1-19 19:33:29

如何强制关闭位于某磁盘内的进程?

我需要做一个程序,强制断开虚拟盘,但如果虚拟盘正在被使用,则导致断开失败,请问如何强制卸下卷或强制关闭位于该盘符下的程序及打开的EXplorer窗口

cls822001 发表于 2010-1-19 22:21:28

强制卸下卷 可以用chkdsk命令

6FINGERS 发表于 2010-1-27 11:14:02

人太懒!代码写的粗糙!楼主看下原理!自己改改!$list = ProcessList()
for $i = 1 to $list
IF StringLeft(_Api_ProcessPath($list[$i]),2)="D:" Then ProcessClose($list[$i])
next



Func _Api_ProcessPath ( $iPID )
        Local $aProc = DllCall ( 'kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR ( 0x0400, 0x0010 ), 'int', 0, 'int',

$iPID )
        If $aProc = 0 Then Return SetError ( 1, 0, '' )
        Local $vStruct = DllStructCreate ( 'int' )
        DllCall ( 'psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc, 'ptr', DllStructGetPtr ( $vStruct ), 'int',

DllStructGetSize ( $vStruct ), 'int*', 0 )
        Local $aReturn = DllCall ( 'psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc, 'int', DllStructGetData (

$vStruct, 1 ), 'str', '', 'int', 2048 )
        If StringLen ( $aReturn ) = 0 Then Return SetError ( 2, 0, '' )
        Return $aReturn
EndFunc
页: [1]
查看完整版本: 如何强制关闭位于某磁盘内的进程?