View Issue Details

IDProjectCategoryView StatusLast Update
0000180OpenMPTUser Interfacepublic2012-03-08 23:09
Reporterjmichae3 Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionno change required 
Platformxp pro sp3 32-bitOSxp pro sp3 32-bitOS Versionxp pro sp3
Product VersionOpenMPT 1.19.03.00 (upgrade first) 
Summary0000180: shortcut to web site is not proper
Description

shortcut to web site, if NSIS was made was using probably the CreateShortCut command, which is wrong. there is a better way.
WriteINIStr "${filepathAppTitle}.url" "InternetShortcut" "URL" "${targetUrl}"

Steps To Reproduce

install openmpt
examine start menu to see icon for web site shortcut. it is an "unknown icon" icon.

Additional Information

the code below I basically deroved from AfroUK's counter code. it creates shortcuts for 32 and 64-bit programs where you have the need for a default path (working directory) you can set for each shortcut and 32-bit DLL's and EXE's to be stored in say, a 32\ directory, while 64-bit executables and DLL's can be stored in a 64\ directory. this allows different 32/64-bit runtime DLL's with the same name as is the case with the mingw-w64 compiler. it also happens to create URL shortcuts the proper way.

;Author: Jim Michaels jmichae3@yahoo.com, Stu (AfroUK)
;Abstract: macro to create a simplistic internet shortcut (.url) or regular
; program/help/document shortcut (.lnk) with working directory.
;Version: 1.2
;Creation Date: 4/18/2011
;Current Date: 4/18/2011

;credit for using Push and Pop for $OUTDIR and using SetOutPath to set the working dir goes to Stu.
;credit for counter idea comes from logiclib.nsh By dselkirk@hotmail.com and eccles@users.sf.net with IfNot support added by Message

;shortcut - macro that makes a basic shortcut with a working directory or an internet shortcut with no working directory.
;usage: !insertmacro shortcut urlORlnk filepathAppTitle targetAbsFilepathOrUrl workingDir
;example:
; !include 'x64.nsh'
; !include 'logiclib.nsh'
; !insertmacro shortcut url '$SMPROGRAMS\$StartMenuFolder\site' 'http://JesusnJim.com/code/windows-dos/pwdgen.html' ''
; ${If} ${RunningX64}
; !insertmacro shortcut lnk '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}' '$INSTDIR\64\pwdgengui64.exe' '$INSTDIR\64\'
; ${Else}
; !insertmacro shortcut lnk '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}' '$INSTDIR\32\pwdgengui.exe' '$INSTDIR\32\'
; ${EndIf}
;instanceId must start with an alpha character and contain only digits, alphas and underscores.
;filepathtitle must not contain a file extension. you should put in a whole filepath.
;targetBaseFilepathNoExtOrUrl should be the entire filepath to the target executable or document, help file, etc if you specified 'lnk' as a shortcutType or a URL if you specified 'url' as the shortcutType.
;workingDir is the absolute path directory that the shortcut will consider the default directory. In windows XP, this is the shortcut's "Start In:" field.

!ifndef _SHORTCUTCOUNTER
!define _SHORTCUTCOUNTER 0
!macro shortcut urlORlnk filepathAppTitle targetAbsFilepathOrUrl workingDir
;handle like a switch statement the various shortcutType
StrCmp ${urlORlnk} "url" shortcut${_SHORTCUTCOUNTER}url +1
StrCmp ${urlORlnk} "lnk" shortcut${_SHORTCUTCOUNTER}lnk +1
;-----without the messagebox, this macro will silently fail if you feed shortcutType garbage.
;MsgBox MB_OK "The macro 'shortcut' had a problem: the author fed it the garbage '${shortcutType}'. Report the bug."
Goto
shortcut${_SHORTCUTCOUNTER}end
shortcut${_SHORTCUTCOUNTER}url:
WriteINIStr "${filepathAppTitle}.url" "InternetShortcut" "URL" "${targetAbsFilepathOrUrl}"
Goto shortcut${_SHORTCUTCOUNTER}end
__shortcut${_SHORTCUTCOUNTER}lnk:
Push $OUTDIR
SetOutPath "${workingDir}"
CreateShortCut "${filepathAppTitle}.lnk" "${targetAbsFilepathOrUrl}"
Pop $OUTDIR
Goto
shortcut${_SHORTCUTCOUNTER}end
shortcut${_SHORTCUTCOUNTER}end:
!define __SHORTCUTCOUNTER ${_SHORTCUTCOUNTER}
!undef _SHORTCUTCOUNTER
!define /math _SHORTCUTCOUNTER ${
SHORTCUTCOUNTER} + 1
!undef __SHORTCUTCOUNTER
!macroend
!endif

TagsNo tags attached.
Has the bug occurred in previous versions?don't know
Tested code revision (in case you know it)

Activities

Saga Musix

Saga Musix

2011-09-07 10:23

administrator   ~0000417

1) We do not use NSIS but InnoSetup
2) The start menu shortcut points to "ModPlug Central.url"
3) "ModPlug Central.url" is created using
Filename: {app}\ModPlug Central.url; Section: InternetShortcut; Key: URL; String: http://forum.openmpt.org/; Flags: createkeyifdoesntexist
Which is the recommended method to create an internet shortcut in InnoSetup.

The shortcut in the start menu is clickable and opens the website, as it should do. I don't see anything that's wrong with it?

jmichae3

jmichae3

2011-09-08 20:45

reporter   ~0000440

as I discovered by myself some time ago, this method is functional. but it is not proper.

real Internet Shortcuts are an .INI file renamed as a .url (have you ever opened one in a text editor?). and so they are in the start menu. If innosetup has any functions for writing .ini files, that would be the proper function for writing a .url file.

as I stated before, the icon's look is broken. normally a web icon will look like the icon of the default browser. doing it this way does not. I used to do the same thing in my programs until I learned how to do it correctly.

If innosetup does not have the write-an-INI facility, then I guess you can close this bug. I use NSIS.

Saga Musix

Saga Musix

2011-09-08 20:48

administrator   ~0000441

The source code I just quoted writes an INI file that has an URL extension. Windows probably just has a problem finding an icon for the linked URL file in the start menu. That is probably the least problem I could care about, since it looks like OpenMPT is not the only program with that "problem" - I got plenty of plain white icons in my start menu, mostly pointing to URLs, TXTs and similar documents. It is probably by design, since neither OpenMPT nor those other programs specifiy an explicit icon file to use for the link.

jmichae3

jmichae3

2011-09-08 21:20

reporter   ~0000443

Last edited: 2011-09-08 21:39

this should be the appropriate innosetup code. I am not used to innosetup, but I don't mind learning something new.

[INI]
Filename: "ModPlug Central.url"; Section: "InternetShortcut"; Flags: uninsdeletesection
Filename: "ModPlug Central.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://forum.openmpt.org/"

so here's your patch.

what's in the latest release does not write an INI file, it creates a binary shortcut file. .ini files are text files. it basically looks like this:

[InternetShortcut]
URL=http://JesusnJim.com/code/windows-dos/phone.html

anything after that may be binary or it may be text.

Saga Musix

Saga Musix

2011-09-08 21:22

administrator   ~0000444

Uhm, sorry, but the URL file is perfectly valid. You don't have to create sections before adding keys to them. Just look at the URL file itself and you'll see that it's valid. It's merely the start menu item that doesn't show an icon, like so many other start menu items of other programs, as I've said.

jmichae3

jmichae3

2011-09-08 21:48

reporter   ~0000445

I won't argue.

Saga Musix

Saga Musix

2011-09-08 22:00

administrator   ~0000446

Last edited: 2011-09-08 22:01

C:\Program Files (x86)\OpenMPT>more "ModPlug Central.url"
[InternetShortcut]
URL=http://openmpt.com/forum/

Yes, there is a valid INI file in OpenMPT's directory. And yes, the start menu item is a shortcut.

jmichae3

jmichae3

2011-09-08 22:40

reporter   ~0000447

hmm. interesting: on your installation it comes out proper. but on mine it does not.

I am on xp pro sp3 32-bit (which may make a difference, I don't know). my shortcut contents are char garbage (but opens up to web site). I could put contents here but mantis would probably choke on it. mine is not an INI file format, but shortcut format. yours is in INI file format. take a second look at your source. I am using 1.19.03.00

Saga Musix

Saga Musix

2011-09-08 23:17

administrator   ~0000448

I've just tried it on WinXP myself, and, in contrast to Win7, it even shows an Internet Explorer icon in the start menu there, so the (binary) .lnk file in the start menu is correctly pointing to the (INI text) .url file there, just like on Win7. And as long as it does that, everything's OK, I guess?

jmichae3

jmichae3

2011-09-09 00:00

reporter   ~0000449

[Icons]
; start menu
Name: {group}{cm:LaunchProgram,OpenMPT}; Filename: {app}\mptrack.exe
Name: {group}{cm:UninstallProgram,OpenMPT}; Filename: {uninstallexe}
Name: {group}\ModPlug Central; Filename: {app}\ModPlug Central.url
Name: {group}\Configuration files; Filename: {userappdata}\OpenMPT\; Tasks: not portable

here, you should not be creating an icon for the .url file. the .url file created in the [INI] section IS the icon/shortcut. when you do this right, windows will automatically create the icon for this when you open the start menu and it will look like the default web browser's icon.

[INI]
; enable portable mode
Filename: {app}\mptrack.ini; Section: Paths; Key: UseAppDataDirectory; String: 0; Flags: createkeyifdoesntexist; Tasks: portable
; internet shortcut
Filename: {app}\ModPlug Central.url; Section: InternetShortcut; Key: URL; String: http://forum.openmpt.org/; Flags: createkeyifdoesntexist

here for the .url file, {app} should be {group} because the .INI format .url file is supposed to be created in the start menu, not in the application directory! both .lnk and .url files are shortcuts (different kinds, one is a document/program shortcut, and the other is an internet shortcut).
I used to do this too: in nsis (I know you use innosetup) I used to make the .url file in the app directory and then create a shortcut to it in the start menu, because that (I thought) was the only way I could get URL's to work. I had never considered writing the .url file directly into the start menu, which is the proper way to do it. now things look and work great.

I hope this helps.

Saga Musix

Saga Musix

2011-09-09 11:02

administrator   ~0000450

Placing LNK files instead of the actual URL file in the start menu is common among all kinds of software and there is no Windows guidline that forbids doing that.

Issue History

Date Modified Username Field Change
2011-09-07 07:03 jmichae3 New Issue
2011-09-07 10:23 Saga Musix Note Added: 0000417
2011-09-08 20:45 jmichae3 Note Added: 0000440
2011-09-08 20:48 Saga Musix Note Added: 0000441
2011-09-08 21:20 jmichae3 Note Added: 0000443
2011-09-08 21:22 Saga Musix Note Added: 0000444
2011-09-08 21:39 jmichae3 Note Edited: 0000443
2011-09-08 21:48 jmichae3 Note Added: 0000445
2011-09-08 22:00 Saga Musix Note Added: 0000446
2011-09-08 22:01 Saga Musix Note Edited: 0000446
2011-09-08 22:40 jmichae3 Note Added: 0000447
2011-09-08 23:17 Saga Musix Note Added: 0000448
2011-09-09 00:00 jmichae3 Note Added: 0000449
2011-09-09 11:02 Saga Musix Note Added: 0000450
2012-03-08 23:09 Saga Musix Status new => closed
2012-03-08 23:09 Saga Musix Resolution open => no change required