Skip to content
⌘ NSIS Forum Archive

File Association / What am I doing wrong? WinXP vs. Win2K

18 posts

ijerkovi#

File Association / What am I doing wrong? WinXP vs. Win2K

This piece of code seems to work on my XP box while on windows 2000 it does not?? I am also having trouble in picking up the appropriate icon from the cView (third party app). Help?!
ijerkovi#
The Code (I forgot to attach)

Function fileAssociation
;create file association
ReadRegStr $0 HKCR "Applications\cView.exe\shell\open\command" ""

StrCpy $9 " $\"%1$\""
StrCpy $1 $0
; remove end characters
Call removeFromString

; remove inital quote
StrCpy $9 "$\""
Call removeFromString

; remove end quote
StrCpy $9 "$\""
Call removeFromString

WriteRegStr HKCR ".rpt" "" "Applications\cView.exe"
WriteRegStr HKCR ".rpt\DefaultIcon" "" $1,0

WriteRegStr HKCR "Applications\cView.exe" "" "cView File"
WriteRegStr HKCR "Applications\cView.exe\shell" "" "open"
FunctionEnd
Joost Verburg#
Try this code

ReadRegStr $0 HKCR "Applications\cView.exe\shell\open\command" ""

WriteRegStr HKCR ".rpt" "" "rptfile"

WriteRegStr HKCR "rtpfile\DefaultIcon" "" "$0,0"
WriteRegStr HKCR "rtpfile" "" "cView File"
WriteRegStr HKCR "rtpfile\shell\open\command" "" "$0"
ijerkovi#
See the thing is that the following line:
ReadRegStr $0 HKCR "Applications\cView.exe\shell\open\command" ""

returns something like this "c:\Profram Files\prog.exe" "%1"

That is why I have to trim it out...

Should I try your code anyways?
ijerkovi#
Didn't work

When I tried to click on a rpt file a windows dialog box opened and asked me with which application I would like to open the file.
ijerkovi#
Almost there!!

It seems to start the acView application but!! it does not open the rpt file?!

I think there might be a problem with the input parameter "%1" somewhere??
ijerkovi#
when I do start run: C:\Program Files\cView\cView.exe

works like a charm and opens up!
but when I do something like this:

C:\Program Files\cView\cView.exe file.rpt
it does not open the file

funny thing is that if I manually set it up (association) it opens the file.
ijerkovi#
I think I know where the problem is: here is the scenario...
1) i am using windows XP
2) when I got to Folder Options | File Types | then select .RPT | Advanced
3) then choose Edit
4) then delete "%1"
It starts working!!
ijerkovi#
the only question is how do I reolve this finding to code above and that the proper icon starts showing up? Your help is greatly appreciated!!
ijerkovi#
this is what got it to work!
ReadRegStr $0 HKCR "Applications\cView.exe\shell\open\command" ""
;MessageBox MB_OK "$0"

WriteRegStr HKCR ".rpt" "" "rptfile"

WriteRegStr HKCR "rptfile\DefaultIcon" "" "$0,0"
WriteRegStr HKCR "rptfile" "" "cView File"
WriteRegStr HKCR "rptfile\shell\open\command" "" "$0"

StrCpy $9 " $\"%1$\""
StrCpy $1 $0
Call removeFromString
WriteRegStr HKCR "rptfile\shell\open\command" "" "$1"


The only thing left is now the icon??