Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; http://www.autoitscript.com/forum/topic/96988-winapi-findexecutable-replacement/page__view__findpost__p__697477
- ; поправил для своих задач. Если не возвращает путь, то возвращает ошибку.
- $Editor=_FileAssociation('.txt')
- If @error Then $Editor=@SystemDir&'\notepad.exe'
- MsgBox(0, 'Сообщение', $Editor)
- Func _FileAssociation($sExt)
- Local $aCall = DllCall("shlwapi.dll", "int", "AssocQueryStringW", _
- "dword", 0x00000040, _ ;$ASSOCF_VERIFY
- "dword", 2, _ ;$ASSOCSTR_EXECUTABLE
- "wstr", $sExt, _
- "ptr", 0, _
- "wstr", "", _
- "dword*", 65536)
- If @error Then Return SetError(1, 0, "")
- If Not $aCall[0] Then
- Return SetError(0, 0, $aCall[5])
- ElseIf $aCall[0] = 0x80070002 Then
- Return SetError(1, 0, "{unknown}")
- ElseIf $aCall[0] = 0x80004005 Then
- Return SetError(1, 0, "{fail}")
- Else
- Return SetError(2, $aCall[0], "")
- EndIf
- EndFunc ;==>_FileAssociation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement