Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign a specific icon to a file

Status
Not open for further replies.

selimsl

Programmer
Aug 15, 2005
62
TR
Hi!

I created a specific file using file system object

Code:
Set tstream = FSys.CreateTextFile("C:\selim.svr", True)
The extension of my file is *.svr.But this file hasn't any icon.I want to assign a icon to this file.Has anyone tried this job?

Thanks in advice.
 
I never did it, but I suspect you would need to do something in registry. You might want to read about what is going on in the system when we assign the icon to specific extentions and then just recreate that hidden things manually in VB. You could ask that preliminary question in Desktop Software forums on this site.

This is my wild guess.

vladk
 
The trick is to associate the extension with an application, where the application has a default icon (it doesn't actually have to be a runnable application)

1) Create an Key for your application (eg MyApp) under HKEY_CLASSES_ROOT, and add a key under that called 'Default Icon'. Set the value of that to your desired icon (e.g if you want the first icon out of the VB^ executable you'd enter "C:\program files\microsoft visual studio\VB98\vb6.exe, 1")

2) Add your extension (including the .) as a Key under HKEY_CLASSES_ROOT (i.e. .svr), and set the default value of that key to that of your application's entry (MyApp)
 
strongm,

This is what I meant: the application (this is quite obvious)

GetSetting, SaveSetting?

vladk
 
GetSetting and SaveSetting won't help; you need to use the Registry API calls.
 
See also thread713-631138 and related MSDN article mentioned there.
 
<GetSetting and SaveSetting won't help

They won't help because getsetting and savesetting save in a specific area of the registry (HKEY_CURRENT_USER\Software\VB and VBA Program Settings) which you can't change.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top