Register a file extension and asign it the ico of the execut
Register a file extension and asign it the ico of the execut
Hi,
I want to register some file extension and asign to this extension some ico (maybe the ico of an exe or dll).
Can anybody point me in the right direction please?
I want to register some file extension and asign to this extension some ico (maybe the ico of an exe or dll).
Can anybody point me in the right direction please?
ARGENTINA WORLD CHAMPION
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Register a file extension and asign it the ico of the ex
It's not really a job for the App itself, but the Installer, and most installers make the registration of file extensions and associated icons pretty easy.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Register a file extension and asign it the ico of the ex
Its on the registry but wirh my alzheimer (not really, but virtual alzheimer he he) i dont remember where do i have the code to set this on the registry.
ARGENTINA WORLD CHAMPION
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Register a file extension and asign it the ico of the ex
You could give this a try. I ripped it out of my QuickUpload application from 7 years ago:
Code: Select all
Procedure ContextMenuAddAll(programfriendlyname$, programpath$, state=1, includefolders=0)
; netmaestro November 2007
Protected key.l = #HKEY_CLASSES_ROOT
Protected path$ = "*\shell\"+programfriendlyname$+"\command"
Protected value$ = ""
Protected string$ = programpath$+" "+Chr(34)+"%1"+Chr(34)
Protected keyresult.l
If state
RegCreateKey_(key,@path$,@keyresult)
RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,Len(string$))
If includefolders
path2$ = "directory\shell\"+programfriendlyname$+"\command"
RegCreateKey_(key, @path2$, @keyresult)
If RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,Len(string$)) = #ERROR_SUCCESS
result = 1
Else
result = 0
EndIf
EndIf
Else
path$ = "*\shell\"+programfriendlyname$+"\command"
RegDeleteKey_(key,@path$)
path$ = "*\shell\"+programfriendlyname$
result1 = RegDeleteKey_(key,@path$)
If includefolders
path2$ = "directory\shell\"+programfriendlyname$+"\command"
RegDeleteKey_(key,@path2$)
path2$ = "directory\shell\"+programfriendlyname$
result2 = RegDeleteKey_(key,@path2$)
If result1 =#ERROR_SUCCESS And result2 = #ERROR_SUCCESS
result = 1
Else
result = 0
EndIf
Else
If result1 = #ERROR_SUCCESS
result = 1
Else
result = 0
EndIf
EndIf
EndIf
RegCloseKey_(keyresult)
ProcedureReturn result
EndProcedure
BERESHEIT
Re: Register a file extension and asign it the ico of the ex
I will test it, thanks
ARGENTINA WORLD CHAMPION
Re: Register a file extension and asign it the ico of the ex
programfriendlyname is the extension?
What is state? And what is includefolders?
Im trying to fully understand...
Thanks in advance
What is state? And what is includefolders?
Im trying to fully understand...
Thanks in advance
netmaestro wrote:You could give this a try. I ripped it out of my QuickUpload application from 7 years ago:Code: Select all
Procedure ContextMenuAddAll(programfriendlyname$, programpath$, state=1, includefolders=0) ; netmaestro November 2007 Protected key.l = #HKEY_CLASSES_ROOT Protected path$ = "*\shell\"+programfriendlyname$+"\command" Protected value$ = "" Protected string$ = programpath$+" "+Chr(34)+"%1"+Chr(34) Protected keyresult.l If state RegCreateKey_(key,@path$,@keyresult) RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,Len(string$)) If includefolders path2$ = "directory\shell\"+programfriendlyname$+"\command" RegCreateKey_(key, @path2$, @keyresult) If RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,Len(string$)) = #ERROR_SUCCESS result = 1 Else result = 0 EndIf EndIf Else path$ = "*\shell\"+programfriendlyname$+"\command" RegDeleteKey_(key,@path$) path$ = "*\shell\"+programfriendlyname$ result1 = RegDeleteKey_(key,@path$) If includefolders path2$ = "directory\shell\"+programfriendlyname$+"\command" RegDeleteKey_(key,@path2$) path2$ = "directory\shell\"+programfriendlyname$ result2 = RegDeleteKey_(key,@path2$) If result1 =#ERROR_SUCCESS And result2 = #ERROR_SUCCESS result = 1 Else result = 0 EndIf Else If result1 = #ERROR_SUCCESS result = 1 Else result = 0 EndIf EndIf EndIf RegCloseKey_(keyresult) ProcedureReturn result EndProcedure
ARGENTINA WORLD CHAMPION
Re: Register a file extension and asign it the ico of the ex
I found this, but does not work with the icon part
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"
keyValue = "My Application to do something"
Result = RegCreateKey_(#HKEY_CLASSES_ROOT, keyName, @keyPtr)
Result = RegSetValue_(keyPtr, "", #REG_SZ, @keyValue, 0)
;creates instructions for command-line launch
keyValue = 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:\Users\user\Pictures\Iconos\Ico\konfabulator_icon.ico,-1"
Result = RegSetValue_(keyPtr, "DefaultIcon", #REG_SZ, @keyValue, #MAX_PATH)
;creates the actual file association for the specified extension
keyName = ".myp123"
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
ARGENTINA WORLD CHAMPION
Re: Register a file extension and asign it the ico of the ex
> It's not really a job for the App itself
What? Plenty of apps have an option to set file associations.
Mainly image/video viewers, and even PureBasic itself does it.
What? Plenty of apps have an option to set file associations.
Mainly image/video viewers, and even PureBasic itself does it.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Register a file extension and asign it the ico of the ex
Very common in compression programs and audio programs, too.PB wrote:What? Plenty of apps have an option to set file associations.
Mainly image/video viewers, and even PureBasic itself does it.
Best wishes to the PB community. Thank you for the memories.
Re: Register a file extension and asign it the ico of the ex
I think its common to register a file extension and make that it shows the icon of the app.
ARGENTINA WORLD CHAMPION
Re: Register a file extension and asign it the ico of the ex
This works fine for me:
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:\Test.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 = ProgramFilename()
Result = RegSetValue_(keyPtr, "DefaultIcon", #REG_SZ, @keyValue, #MAX_PATH)
;creates the actual file association for the specified extension
keyName = ".myext" ;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)
ARGENTINA WORLD CHAMPION
Re: Register a file extension and asign it the ico of the execut
I know that this is old topic
but i try to compile and seems fine
but file icon is not changed
I am interested only in icon chenge
so i am asking what is wrong ?
or maybe some of you have tiny app with this program i mean GUI app.
thanks in advance !
but i try to compile and seems fine
but file icon is not changed
I am interested only in icon chenge
so i am asking what is wrong ?
or maybe some of you have tiny app with this program i mean GUI app.
thanks in advance !
Re: Register a file extension and asign it the ico of the execut
Code: Select all
RunProgram("ie4uinit -show")
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Register a file extension and asign it the ico of the execut
Thank you but i don't understand both answers
how to clearIconCache() ?
is that function or something else?
what is RunProgram() ?
I never see such a commands before .
Is here anyone who can confirm that above program can change icon of file with
specified extension ?
I know that old DLib IDE can do that programmed by author i guess.
how to clearIconCache() ?
is that function or something else?
what is RunProgram() ?
I never see such a commands before .
Is here anyone who can confirm that above program can change icon of file with
specified extension ?
I know that old DLib IDE can do that programmed by author i guess.