Page 1 of 1
How to get AssociatingFiles
Posted: Thu Apr 05, 2012 4:28 pm
by oryaaaaa
I am using droppyLib, but I need get AssociatingFiles infomation.
coz I didn't understand associate manage registory.
Could you tell me about AssociatingFiles infomation?
1. own app associate by ".mp3"
2.chose ".mp3"
3.get Program path, and programfiles before
4. launch before associated app "abc.mp3"
I am making new audio player. but not support all function.
then my app reject, and before app run
Thank you
Re: How to get AssociatingFiles
Posted: Thu Apr 05, 2012 6:36 pm
by eJan
I'm not sure for PB code, but i can help with Registry:
hold information about mp3 extension, where:
value holds registered file type (mine is "
QMP.audio" = Quintessential Player Audio File)
next step is to read "QMP.audio" = "QMP Audio File" information
where:
Code: Select all
HKEY_CLASSES_ROOT\QMP.audio\shell\open\command
give you the path of audio player which opens the mp3 file, on my comp it is:
Code: Select all
"C:\Program Files\Quintessential Media Player\QMPlayer.exe" /open "%1"
Re: How to get AssociatingFiles
Posted: Thu Apr 05, 2012 6:42 pm
by ts-soft
Code: Select all
Procedure.s FindAssociatedProgram(File.s)
Protected Result.s = Space(#MAX_PATH)
Protected Error
Error = FindExecutable_(@File, 0, @Result)
If Error <= 32
Select Error
Case #SE_ERR_FNF
Debug "The specified file was not found"
Case #SE_ERR_PNF
Debug "The specified path is invalid"
Case #SE_ERR_ACCESSDENIED
Debug "The specified file cannot be accessed"
Case #SE_ERR_OOM
Debug "The system is out of memory or resources"
Case #SE_ERR_NOASSOC
Debug "There is no association for the specified file type with an executable file"
Default
Debug "Unknown error"
EndSelect
ProcedureReturn ""
EndIf
ProcedureReturn Result
EndProcedure
Define.s File = GetTemporaryDirectory() +"tmp.mp3"
Define FF = CreateFile(#PB_Any, File)
If FF
CloseFile(FF)
Debug FindAssociatedProgram(File)
DeleteFile(File)
EndIf
Re: How to get AssociatingFiles
Posted: Fri Apr 06, 2012 9:04 am
by TI-994A
oryaaaaa wrote:I am using droppyLib, but I need get AssociatingFiles infomation.
coz I didn't understand associate manage registory.
Could you tell me about AssociatingFiles infomation?
1. own app associate by ".mp3"
2.chose ".mp3"
3.get Program path, and programfiles before
4. launch before associated app "abc.mp3"
I am making new audio player. but not support all function.
then my app reject, and before app run
Thank you
Hello again, oryaaaaa. If I understand you correctly, this code should do the trick. It creates registry entries to associate the desired file type/extension with your application, and even changes the icons of the associated files to match your application icon:
Code: Select all
;=======================================
;
; Creating registry entries for
; application file association &
; updating associated file icons
;
; by TI-994A - 6th April, 2012
;
;=======================================
#SHCNE_ASSOCCHANGED = $8000000
#SHCNF_IDLIST = $0
Define.s keyName, keyValue
Define.i result, keyPtr
;creates an entry for your application
keyName = "MyApp" ;short name of your app
keyValue = "My Application to do something" ;long description of your app
result = RegCreateKey_(#HKEY_CLASSES_ROOT, keyName, @keyPtr)
result = RegSetValue_(keyPtr, "", #REG_SZ, @keyValue, 0)
;creates instructions for command-line launch
keyValue = "c:\MyAppFileName.exe %1" ;replace with ProgramFilename() + " %1"
result = RegSetValue_(keyPtr, "Shell\Open\Command", #REG_SZ, @keyValue, #MAX_PATH)
;sets the associated file icons to match your application
;the icon keyValue can even be a direct icon, for eg: "c:\someIcon.ico"
keyValue = "c:\MyAppFileName.exe -1" ;replace with ProgramFilename() + ",-1"
result = RegSetValue_(keyPtr, "DefaultIcon", #REG_SZ, @keyValue, #MAX_PATH)
;creates the actual file association for the specified extension
keyName = ".myp" ;can be anything, for eg: ".mp3"
keyValue = "MyApp"
result = RegCreateKey_(#HKEY_CLASSES_ROOT, keyName, @keyPtr)
result = RegSetValue_(keyPtr, "", #REG_SZ, @keyValue, 0)
;effects a system-wide notification of the changes
SHChangeNotify_(#SHCNE_ASSOCCHANGED, #SHCNF_IDLIST, 0, 0)
End
Hope this is helpful for you, and good luck on your audio player project!
Re: How to get AssociatingFiles
Posted: Sun Apr 08, 2012 7:54 pm
by utopiomania
Thanks for the tip, ts-soft.

Re: How to get AssociatingFiles
Posted: Sun Apr 08, 2012 9:54 pm
by flaith
Code: Select all
Enumeration
#ASSOCSTR_COMMAND = 1
#ASSOCSTR_EXECUTABLE
#ASSOCSTR_FRIENDLYDOCNAME
#ASSOCSTR_FRIENDLYAPPNAME
#ASSOCSTR_NOOPEN
#ASSOCSTR_SHELLNEWVALUE
#ASSOCSTR_DDECOMMAND
#ASSOCSTR_DDEIFEXEC
#ASSOCSTR_DDEAPPLICATION
#ASSOCSTR_DDETOPIC
#ASSOCSTR_INFOTIP
#ASSOCSTR_QUICKTIP
#ASSOCSTR_TILEINFO
#ASSOCSTR_CONTENTTYPE
#ASSOCSTR_DEFAULTICON
#ASSOCSTR_SHELLEXTENSION
#ASSOCSTR_DROPTARGET
#ASSOCSTR_DELEGATEEXECUTE
#ASSOCSTR_MAX
EndEnumeration
Enumeration
#ASSOCF_INIT_NOREMAPCLSID = $00000001
#ASSOCF_INIT_BYEXENAME = $00000002
#ASSOCF_OPEN_BYEXENAME = $00000002
#ASSOCF_INIT_DEFAULTTOSTAR = $00000004
#ASSOCF_INIT_DEFAULTTOFOLDER = $00000008
#ASSOCF_NOUSERSETTINGS = $00000010
#ASSOCF_NOTRUNCATE = $00000020
#ASSOCF_VERIFY = $00000040
#ASSOCF_REMAPRUNDLL = $00000080
#ASSOCF_NOFIXUPS = $00000100
#ASSOCF_IGNOREBASECLASS = $00000200
#ASSOCF_INIT_IGNOREUNKNOWN = $00000400
EndEnumeration
pcchOut.l = #MAX_PATH
pszOut.s = Space(255)
flags = #ASSOCF_NOTRUNCATE | #ASSOCF_REMAPRUNDLL
pszAssoc.s = ".xls"
pszExtra.s = "open"
If OpenLibrary(0, "Shlwapi.dll")
*AssocQueryString = GetFunction(0, "AssocQueryStringA")
If *AssocQueryString
hresult = CallFunctionFast(*AssocQueryString, flags, #ASSOCSTR_EXECUTABLE, @pszAssoc, @pszExtra, @pszOut, pcchOut)
Select hresult
Case #S_OK
Debug "Executable name for '"+pszAssoc+"' : "+pszOut
Case #S_FALSE
Debug "pszOut is NULL. pcchOut contains the required buffer size"
Case #E_POINTER
Debug "The pszOut buffer is too small to hold the entire string"
Default
Debug "No association defined for extension '"+pszAssoc+"'"
EndSelect
EndIf
EndIf