找回密码
 加入
搜索
查看: 1658|回复: 2

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

[复制链接]
发表于 2010-1-19 19:33:29 | 显示全部楼层 |阅读模式
我需要做一个程序,强制断开虚拟盘,但如果虚拟盘正在被使用,则导致断开失败,请问如何强制卸下卷或强制关闭位于该盘符下的程序及打开的EXplorer窗口
发表于 2010-1-19 22:21:28 | 显示全部楼层
强制卸下卷 可以用chkdsk命令
发表于 2010-1-27 11:14:02 | 显示全部楼层
人太懒!代码写的粗糙!楼主看下原理!自己改改!
$list = ProcessList()
for $i = 1 to $list[0][0]
IF StringLeft(_Api_ProcessPath($list[$i][1]),2)="D:" Then ProcessClose($list[$i][1])
next



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

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

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

$vStruct, 1 ), 'str', '', 'int', 2048 )
        If StringLen ( $aReturn[3] ) = 0 Then Return SetError ( 2, 0, '' )
        Return $aReturn[3]
EndFunc

评分

参与人数 1金钱 +10 收起 理由
pusofalse + 10 乐于助人。

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 13:44 , Processed in 0.077978 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表