本帖最后由 gto250 于 2014-2-27 20:02 编辑
不解释,自己看
If GetParentProcessName(GetParentProcess())="explorer.exe" Then MsgBox(0,"","禁止双击打开")
Func GetParentProcessName($PID)
Local $list = ProcessList()
For $i = 1 To $list[0][0]
If $list[$i][1]=$PID Then Return $list[$i][0]
Next
Return 0
EndFunc
Func GetParentProcess($PID = 0)
$tagPROCESSENTRY32="dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]"
If Not $PID Then $PID = @AutoItPID
Local $hSnapshot = DllCall('kernel32.dll', 'handle', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
If @error Or Not $hSnapshot[0] Then Return SetError(@error + 10, @extended, 0)
Local $tPROCESSENTRY32 = DllStructCreate($tagPROCESSENTRY32)
Local $Result = 0
$hSnapshot = $hSnapshot[0]
DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
Local $Ret = DllCall('kernel32.dll', 'bool', 'Process32FirstW', 'handle', $hSnapshot, 'struct*', $tPROCESSENTRY32)
Local $iError = @error
While (Not @error) And ($Ret[0])
If DllStructGetData($tPROCESSENTRY32, 'ProcessID') = $PID Then
$Result = DllStructGetData($tPROCESSENTRY32, 'ParentProcessID')
ExitLoop
EndIf
$Ret = DllCall('kernel32.dll', 'bool', 'Process32NextW', 'handle', $hSnapshot, 'struct*', $tPROCESSENTRY32)
$iError = @error
WEnd
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hSnapshot)
If Not $Result Then Return SetError($iError, 0, 0)
Return $Result
EndFunc
|