Advertisement
AZJIO

Untitled

Aug 31st, 2011
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.05 KB | None | 0 0
  1. ; http://www.autoitscript.com/forum/topic/96988-winapi-findexecutable-replacement/page__view__findpost__p__697477
  2. ; поправил для своих задач. Если не возвращает путь, то возвращает ошибку.
  3.  
  4. $Editor=_FileAssociation('.txt')
  5. If @error Then $Editor=@SystemDir&'\notepad.exe'
  6.  
  7. MsgBox(0, 'Сообщение', $Editor)
  8.  
  9. Func _FileAssociation($sExt)
  10.  
  11.     Local $aCall = DllCall("shlwapi.dll", "int", "AssocQueryStringW", _
  12.             "dword", 0x00000040, _ ;$ASSOCF_VERIFY
  13.             "dword", 2, _ ;$ASSOCSTR_EXECUTABLE
  14.             "wstr", $sExt, _
  15.             "ptr", 0, _
  16.             "wstr", "", _
  17.             "dword*", 65536)
  18.  
  19.     If @error Then Return SetError(1, 0, "")
  20.  
  21.     If Not $aCall[0] Then
  22.         Return SetError(0, 0, $aCall[5])
  23.     ElseIf $aCall[0] = 0x80070002 Then
  24.         Return SetError(1, 0, "{unknown}")
  25.     ElseIf $aCall[0] = 0x80004005 Then
  26.         Return SetError(1, 0, "{fail}")
  27.     Else
  28.         Return SetError(2, $aCall[0], "")
  29.     EndIf
  30.  
  31. EndFunc  ;==>_FileAssociation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement