Register a file extension and asign it the ico of the execut

Just starting out? Need help? Post your questions and find answers here.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: Register a file extension and asign it the ico of the execut

Post by jassing »

aston wrote: Fri Jun 02, 2023 2:33 pm how to clearIconCache() ?
is that function or something else?
It's in the source he linked in the post.
aston wrote: Fri Jun 02, 2023 2:33 pm what is RunProgram() ?
See help.
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Register a file extension and asign it the ico of the execut

Post by jacdelad »

@aston: I'm confused, you registered in 2009 and don't know RunProgram?

However, you can type this command into the commandline and execute it. It refreshes your icon cache.
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
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

sorry yes...i really never like to use and simply don't know how to use
CMD..

But i simply don't understand why above code not work ?
It just refresh desktop icons and that is ?
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Register a file extension and asign it the ico of the execut

Post by jacdelad »

Erm...ok. so, CMD refers to the windows console. Type cmd in the search function and start it."ie4uinit" is a program delivered with Windows. That's all.

Sorry if I sounded rude. I'm a bit confused that you as a programmer don't use cmd from time to time. Also, my example was wrapped in code tags, so just copy it into the PureBasic IDE and run it.
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
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

jacdelad

i compiled and get error

Windows cannot find ie4uinit -show

so i must ask .what this program do...

and again is there anyone who can explain to me ricardo program
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: Register a file extension and asign it the ico of the execut

Post by jassing »

aston wrote: Sat Jun 03, 2023 11:38 pm i compiled and get error
Windows cannot find ie4uinit -show
what was your code?

Code: Select all

RunProgram("ie4uinit.exe","-show","")
aston wrote: Sat Jun 03, 2023 11:38 pm so i must ask .what this program do...
Try this link
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

Yeah...
It looks like joke...

I am still waiting for someone who can explain to me
what ricardo code do ...or not work on my win7 computer
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: Register a file extension and asign it the ico of the execut

Post by Axolotl »

Hey aston,
I think the code from above (coded by TI-994A, posted by ricardo) is self-explanatory.
From the comments you can understand what the program does.
I actually wouldn't explain anything else there....
To make it work for you, you should perhaps feed one or the other variable with your information.
For more information on each function you can do an internet search on each function name (without the trailing underscore), I do this in combination with MSDN. Example: MSDN RegCreateKey.

Another Hint:
You can use the regedit.exe (Registry Editor) to check the paths and entries you want create first.

What is ie4uinit.exe?
I have no idea, but you can find answers like this: https://www.file.net/process/ie4uinit.exe.html
TL;DR
It performs operations on the Icon Cache Database, a hidden ".db"-type file in the "%userprofile%\AppData\Local" subdirectory, determined by command-line switches including "-BaseSettings", "-UserIconConfig", "-ClearIconCache", or "-Reinstall." (In Win10 its switches differ.)
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Register a file extension and asign it the ico of the execut

Post by jacdelad »

Hi aston,
sorry for the confusion, of course it hast to be

Code: Select all

RunProgram("ie4uinit.exe","-show","")
exactly like jassing wrote.

The program ie4uinit.exe is provided by Windows and performs operations on the icon cache for the UI and the Windows Explorer and so on. With RunProgram you start the program with the specific parameter to delete and renew the icon cache.
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
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

Hi guys

One of you say ..code is self-explained
yes i think it is and i search trough all possible examples over NET

Is anyone of you try to compile it and see ?
is there any change?

in some other languages seems that this operation require 3 step
but in this PureBasic example there are not in 3 steps
in C program is much larger using similar api calls.

also IconCashe don't have nothing with that ..i think
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Register a file extension and asign it the ico of the execut

Post by AZJIO »

I gave a working version and read 2 pages every day how you deal with the problem.
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: Register a file extension and asign it the ico of the execut

Post by Axolotl »

well, I really use the registry very rarely.

I tried to read the keys and values of an existing entry (Purebasic).
The following code shows me the expected information.

Code: Select all

EnableExplicit 
Procedure.s RegRead(Root, KeyPath.s, ValueName.s) 
	Protected valueData.s, hKey, size, type 

	If #ERROR_SUCCESS = RegOpenKeyEx_(Root, KeyPath, 0, #KEY_READ, @hKey)                 ; open with READ access rights 
		If #ERROR_SUCCESS = RegQueryValueEx_(hKey, ValueName, 0, @type, 0, @size)           ; get type and size 
			ValueData = Space(size)                                                           ; alloc memory 
			If #ERROR_SUCCESS = RegQueryValueEx_(hKey, ValueName, 0, 0, @valueData, @size)    ; get data to return 
			EndIf 
		EndIf
		RegCloseKey_(hKey) 
	EndIf
	ProcedureReturn valueData  ; return the result 
EndProcedure

; show the results (compared to the regedit this works fine) 
Global appname.s 
appname = RegRead(#HKEY_CLASSES_ROOT, ".pb", "") 
Debug "Application : " + appname 
If appname 
  Debug "  DefaultIcon: " + RegRead(#HKEY_CLASSES_ROOT, appname + "\DefaultIcon", "")  
  Debug "  CommandLine: " + RegRead(#HKEY_CLASSES_ROOT, appname + "\Shell\Open\Command", "") 
Else 
  Debug "  Nothing found " + #DQUOTE$ + appname + #DQUOTE$ 
EndIf 
I can imagine that the code needs the correct access rights.
I leave the writing access to you. For your further coding on registry have a look at the following

Code: Select all

 RegCreateKeyEx_()  

And if you need more api error handling then this is very helpful.

Code: Select all

Procedure.s FormatMessage(ErrorCode)   ; 
  ; handle system messages  (LINK: https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes) 
  Protected result.s, *msg, msglen 

  msglen = FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM|#FORMAT_MESSAGE_IGNORE_INSERTS, 0, ErrorCode, 0, @*msg, 0, 0) 
  If msglen 
    result = PeekS(*msg, msglen - 2)   ; remove #CRLF$, acc. to MSDN 
    LocalFree_(*msg) 
  EndIf 
  ProcedureReturn result 
EndProcedure 
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

Yes guys working with registry is not safe if we don't know
what to do..
also i see ..you read registry ..but that TI/99 or ricardo program change registry keys
or create new and change file association with new icon

i found in old files DeanH posted me DLib2
with tiny program file association which have two buttons
associate file with .dsf but there is no source code of that tiny program
and there is no other options ..i mean different file extensions.
so i am still puzzled how might look..
User avatar
aston
User
User
Posts: 64
Joined: Wed Nov 18, 2009 11:18 pm

Re: Register a file extension and asign it the ico of the execut

Post by aston »

sorry but this links are useless
or are complicate and confusing
it seems that i need to investigate C examples
or look somewhere else
Post Reply