I've got a small log v开发者_StackOverflow中文版iewer app to read some custom logs. I can drag files directly onto the executable, and they are loaded through the command line just fine.
However, if I were to drag the files to a desktop shortcut, Windows will not open the application using the files as the command line arguments. It won't open the application at all.
Is there something I am missing?
This is on Windows 7 Enterprise x64, not running with any elevated privileges. This is all written in C#, .NET 4.0 Client framework, etc.
Is your desktop shortcut an advertised shortcut? You cannot drag and drop onto an advertised shortcut. If you are using WiX or the Visual Studio Setup Projects to create a .msi installer for your application, then it's possible that your desktop shortcut which the Windows Installer is creating for you is an advertised shortcut. Also, you can tell whether or not a shortcut is advertised, by right-clicking it, viewing properties, and seeing whether or not the Target field is grayed out. If it is, then it is advertised. One way to prevent this is to set the DISABLEADVTSHORTCUTS property, which is a Windows Installer property. Setting this property will disable all advertised shortcuts for your application.
The simplest way to set or test this is to open the .msi file with Orca, and add a property named DISABLEADVTSHORTCUTS with a value of 1 to the Property table, then try installing it again.
I believe that in order for dragging a file over a shortcut to work, you need to define your application in the registry, and create an open
command registry key for it.
The following link may be a good starting point to find out how to do it. http://msdn.microsoft.com/en-us/library/ee872121%28v=VS.85%29.aspx
Or just look under HKEY_CLASSES_ROOT\Application\notepad.exe
in the registry of your machine, to quickly see an example.
The easiest way is to run the installer with the "DISABLEADVTSHORTCUTS=1" command line option, e.g. setup.msi DISABLEADVTSHORTCUTS=1
精彩评论