Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 29th July 2003, 03:26   #1
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
File Association Problem

I got my file to associate to my application. However, the icon is not getting assigned to the file. Here is my code...it's basically copied directly out of Examples\makensis. Any ideas what is happening?

By the way, I use RefreshShellIcons and I've also rebooted to see if that associates the icon, but those don't work either. Thanks!!!

;Back up old value of .opt
ReadRegStr $1 HKCR ".h2h" ""
StrCmp $1 "" NoBackup
StrCmp $1 "H2H.Document" NoBackup
WriteRegStr HKCR ".h2h" "backup_val" $1
NoBackup:
WriteRegStr HKCR ".h2h" "" "H2H.Document"
ReadRegStr $0 HKCR "H2H.Document" ""
StrCmp $0 "" 0 skipOPTAssoc
WriteRegStr HKCR "H2H.Document" "" "H2H File"
WriteRegStr HKCR "H2H.Document\shell" "" "open"
WriteRegStr HKCR "H2H.Document\DefaultIcon" "" $INSTDIR\${MUI_FILE},1
skipOPTAssoc:
WriteRegStr HKCR "H2H.Document\shell\open\command" "" '$INSTDIR\${MUI_FILE} "%1"'
jcagle is offline   Reply With Quote
Old 29th July 2003, 06:29   #2
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
Try this code:
code:
;Back up old value of .opt
ReadRegStr $1 HKCR ".h2h" ""
StrCmp $1 "" NoBackup
StrCmp $1 "H2H.Document" NoBackup
WriteRegStr HKCR ".h2h" "backup_val" $1
NoBackup:
WriteRegStr HKCR ".h2h" "" "H2H.Document"
ReadRegStr $0 HKCR "H2H.Document" ""
StrCmp $0 "" 0 skipOPTAssoc
WriteRegStr HKCR "H2H.Document" "" "H2H File"
WriteRegStr HKCR "H2H.Document\shell" "" "open"
WriteRegStr HKCR "H2H.Document\DefaultIcon" "" $INSTDIR\${MUI_FILE},0
skipOPTAssoc:
WriteRegStr HKCR "H2H.Document\shell\open\command" "" '$INSTDIR\${MUI_FILE} "%1"'

Note the 0 on the 3rd last line. I think that your exe has only 1 icon and since the icon list starts from 0 windows cannot find the 2nd icon, which does NOT exist.

Vytautas
Vytautas is offline   Reply With Quote
Old 29th July 2003, 13:13   #3
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
You are correct...my .exe only has one icon. I'll give your example a try and let you know how it turns out!!! Thanks!!
jcagle is offline   Reply With Quote
Old 29th July 2003, 13:33   #4
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
Ok, it worked...but, not like expected!

First, since my last installation/uninstallation left the H2H.Document (see above example) in the registry, the change from:
WriteRegStr HKCR "H2H.Document\DefaultIcon" "" $INSTDIR\${MUI_FILE},1
to:
WriteRegStr HKCR "H2H.Document\DefaultIcon" "" $INSTDIR\${MUI_FILE},0
did not occur properly...so, I had to do it manually. But, THEN it worked!

Second (now for the unexpected part), when I associate the files via the Folder Options...|File Types, the icon of the files has the icon of the .exe on a piece of paper...similar to how a .doc looks. This is what I want it to look like (the "on a piece of paper" way, that is). However, doing it the "makensis" way, I actually get the same icon as the .exe. Does anyone have any ideas on how to programmatically do what the Folder Options... is doing?
jcagle is offline   Reply With Quote
Old 29th July 2003, 13:40   #5
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
Not sure about that one, which version of Windows do you have since the Folder Options way is supposed to have the same icon, i.e. identical to your exe icon. Usually if you want a document icon to have a 'paper' in the background you would have to create another icon which look like that and include that icon in either the exe file or as an .ico file with your installation.

Vytautas
Vytautas is offline   Reply With Quote
Old 29th July 2003, 14:45   #6
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
That's interesting. It did it on Windows ME, but I can't re-produce it on Windows 2000 Professional!?!?!? If someone has Windows ME, could you try to use Folder Options... and associate a file and see what happens? I'm away from my home PC right now (which has Windows ME), else I would try it myself.
jcagle is offline   Reply With Quote
Old 30th July 2003, 12:36   #7
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
I don't know why, but I can't get this to work anymore. At one time, I associated my files with an icon, and the resulting desktop icon was my selected icon on a "blank sheet of paper" icon...like the .doc icon where the "W" is on the blank sheet of paper. Since I did it once, I'm assuming that I can do it again. Does anyone know how this is done?
jcagle is offline   Reply With Quote
Old 30th July 2003, 13:33   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
In Folder Options, I achieve it by telling my .bsp file extension to open in a certain program (in my case Quake2maX) and it shows the Quake2maX icon on a piece of paper as the file extension logo.
It's only after I click "Change Icon" that I can force Windows to display the full exe logo on my .bsp file icons.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th July 2003, 14:04   #9
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
Can this be accomplished with setting some registry settings while doing an file association during installation? (that you know of?)
jcagle is offline   Reply With Quote
Old 30th July 2003, 14:37   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Try
WriteRegStr HKCR ".bsp" "" "BSPFile"
WriteRegStr HKCR "BSPFILE\Shell\Open\Command" "C:\quake2\quake2max.exe"

Make sure you config it to your own file extension.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th July 2003, 14:39   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
You should look at this:

http://nsis.sourceforge.net/archive/...instances=0,11

The WriteRegStr that writes the DefaultIcon value sets the icon of your extension.
Without this, Windows will (I think) just put the application logo on a piece of paper.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th July 2003, 15:33   #12
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
The link you sent me is exactly what I tried...but, it just uses the application logo...not the logo on a piece of paper.

One of the things I see different between what you posted and in the link gave, is:
WriteRegStr HKCR "BSPFILE\Shell\Open\Command" "C:\quake2\quake2max.exe"

as opposed to this:
WriteRegStr HKCR "BSPFILE\Shell\Open\Command" "" 'C:\quake2\quake2max.exe "%1"'

Have you used your posting in an actual application? Did it put your logo on a piece of paper?
jcagle is offline   Reply With Quote
Old 30th July 2003, 15:39   #13
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Use the same code I gave you the link to, but remove...
WriteRegStr HKCR "OptionsFile\DefaultIcon" "" $INSTDIR\execute.exe,0
...from the script.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 30th July 2003, 16:19   #14
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
I will give that a shot when I get back to my home PC (which is where my app is). Thanks a lot for your help!!!
jcagle is offline   Reply With Quote
Old 31st July 2003, 00:01   #15
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
I finally got this to work...kind of...I could only get it to work if the $INSTDIR was in DOS format (you know, with the ~1 etc...) in the following line:
WriteRegStr HKCR "H2H.Document\shell\open\command" "" '$INSTDIR\${MUI_FILE} "%1"'

So, I guess I have 2 questions:
1) Is that really the case? To get this to work properly, do I really have to have the DOS format for the path?
2) If I DO have to have it in DOS format, is there some sort of converter that I can use in my NSIS script that will do this conversion for me?

Thanks!!
jcagle is offline   Reply With Quote
Old 31st July 2003, 10:11   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Have a look in NSIS documentation.
I thinks theres a command to convert paths to DOS format.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 31st July 2003, 10:12   #17
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Try this:
code:
WriteRegStr HKCR "H2H.Document\shell\open\command" "" "$\"$INSTDIR\${MUI_FILE}$\" $\"%1$\""


-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 31st July 2003, 13:10   #18
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
I didn't try your example, Afrow, but I did get this to work:

GetFullPathName /SHORT $R1 $INSTDIR
WriteRegStr HKCR "H2H.Document\shell\open\command" "" "$R1\${MUI_FILE} %1"

Do you think your example is a better way of doing it, or is this way better?
jcagle is offline   Reply With Quote
Old 31st July 2003, 15:15   #19
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Mine will be better.
I'm simply placing quotes " " around the parts, as I expect it's not working correctly because $INSTDIR has spaces in it.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 31st July 2003, 17:01   #20
jcagle
Senior Member
 
Join Date: Jul 2003
Posts: 103
I'll give your way a shot and let you know how it turns out, Afrow. And, as usual, Thanks a lot for your help!
jcagle is offline   Reply With Quote
Old 31st July 2003, 19:13   #21
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
No problem

I like to help!

-Stu [15 year old kid]

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump