How to start the associated program when selecting more than one files? - file

I have set .jpg file associated to my own program. I want to add the context menu to .jpg files, so I set the entry of HKCR.jpg\shell\open\command to "myProg.exe %1". After associating, there will be an item on the top of the context menu saying "Open image with myprog". This works right when I select a single .jpg file, but when I selected more than one file and click the top item of the context menu, nothing happended. How can I solve the problem?
Thank you very much

Each selected file will be sent to a new instance of your application. Your application should check if a previous version exists, or not. If a previous instance exists, it should sent its parameters to it (e.g. using Windows Messages) and then terminate.
Another approach is to use DDE (Dynamic Data Exchange), an old method used by Shell to send all files to one instance of your program.

You might need double quotes around the "%1".
Read this article for much more detailed information about how all this works.
http://msdn.microsoft.com/en-us/library/bb776883.aspx
Also, this blog entry talks about what you need to do specifically for multi-select command execution: http://blogs.msdn.com/pix/archive/2006/06/30/652889.aspx

Related

How to get the icon path and index associated with a file type (again, with clarity)?

It's a long shot, but does anyone know of a working method to get the associated icon location (= path to an exe/dll/ico file) and ID for a given filename with WinAPI. The point is to create a shortcut to another file (which may or may not be of the same file type) and set THIS exact icon, overriding its default one, presumably with IShellLink::SetIconLocation.
Things that don't work:
-ExtractAssociatedIcon
-SHGetFileInfo
-IExtractIcon
Return random crap with GIL_NOTFILENAME flag set for any of the default file types I've tried (like txt).
There seem to be several topics on SO about this sorta thing, with answers/non-answers suggesting one of the above. This one [1] appears most close to being informative. Their preferred method doesn't work either, but their other notes gave me the hint to try using the registry.
So for the time being, I wrote my own function that uses the registry [2], but it's also not perfect: in some cases, the registry stores 'positive icon IDs' that cannot, it seems, be used with SetIconLocation.
Honestly didn't expect this to be such a year 2023 problem
You don't need to call IShellLink::SetIconLocation if you don't want to override the targets default icon. Just point the shortcut to a .txt file and the shortcut automatically gets the correct icon.
Positive icon IDs most certainly can be used with SetIconLocation, that is the common case. Are you calling PathParseIconLocation?
GIL_NOTFILENAME is just something you have to accept, it usually means the icon comes from the system image list. The shell is mainly interested in going from a file/type to a HICON, not the other way around. The icon for a file may even be dynamic if it is implemented by a shell extension.
You can add AssocQueryString to the list of functions to try that will never work 100% of the time...

How do I prevent VS Code from trying to save all unsaved files on hotkey save command and save only the current one?

I have a tendency to have multiple unsaved notes and code segments open intentionally in VS Code. I don't want to save them. This is just a holding place as I work on stuff and then I want it to go away.
Currently, when I go to save a new file I want to keep while have several others I don't want to keep, it goes through a list of all of them and tries to save them each one at a time. I don't want that. I just want to save the file in the current viewport.
The hotkey I use is Command + S (which is the default "Save" hotkey on Mac OS X). Note that in VS Code's menu, it states that the "Save All" hotkey is Option + Command + S.
Is there a way to have it ignore the other unsaved files when saving the current one?
I know this is too late, but it might help other people.
To save all files and don't want VS code to ask to save completely unsaved files, you can use the below keyboard shortcut.
File.Save All Files (workbench.action.files.saveFiles)
This will only save previously saved files.
Hope this helps.

Installshield 2011: Take path from one window, take text from second

Good day, everyone. I have that task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will prompt user to enter a path and create text file in this specified location, while second will promt for text input and save anything user writes into this text file.
Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.
Question is - what exact dialog windows/functions/points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project" but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
For future reference, here's working solution.
Asked that same question at flexera forums, and here's what I got:
Off the top of my head (without InstallShield handy to check this) 1)
Create an InstallScript project, just accept all of the defaults in
the new project wizard unless you want to add localization or
something. 2) Your description implies that you do not need
maintenance (repair, modify, uninstall) support. If correct go to
Project\Settings and on the Maintenance tab select 'no uninstall or
maintenance'. 3) You can put your code at the top of the
OnFirstUIBefore function and then call Exit so that the rest of that
default code is never executed, since you are not installing anything.
As part of your InstallShield IDE, in the Start menu (for IS2012
Spring) is a tool that demonstrates all of the built in dialogs. You
can look through those choices and select the dialog that is best for
your situation. It sounds like you want to:
Call AskPath or SdAskDestPath (there are several other possibilities)
Then call AskText and save that string.
If you need to make layout or text changes to the default dialogs look
at your Dialogs view and select which ever dialog you selected above
and edit it. (If you decide to use skins make sure you select the skin
before you make any dialog layout changes.)
Then do something similar to the functional body of the WriteLine
example http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm
The actual WriteLine example function prototype is for a MSI custom
action which is not what you want. Ignore the function protoype and
just use the code in your project to create the file at the path you
already collected and write the line of text that you collected.
Then call Exit;
(big thanks to user phill_mn for that answer)
And here's the code for setup.rul:
#include "ifx.h"
function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;
begin
AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);
MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);
AskText ("Please enter some text to save into that file", "Text goes here", svResult);
OpenFileMode (FILE_MODE_APPEND);
if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;
CloseFile (nvFileHandle);
Do(EXIT);
return 0;
end;

Show help in c# showing proper topic but wrong content in CHM

Below is the code I am using to show my CHM file.
Help.ShowHelp(control, HelpFile, HelpNavigator.Topic, topic);
topic="/foo_Manual/foo-Define_Technologies_1-Chapter9/Defining_foo.htm.";
It is opening the proper html widow in the right; however, the left side's contents tab is always pointing to 1st chapter.
Try this one
Help.ShowHelp(Control, HelpFileName, HelpNavigator.TopicId, TopicID);
This depends on the way your CHM file is compiled and/or the last user action.
But you need AutoSync too (see attached picture of HTMLHelp Workshop).
Please note one that the last visited tab is saved to a hh.dat file: When a CHM file is compiled, you can define the default tab displayed when the file is opened. If a user opened one of the other tabs (e.g. the index) and closes the file, the next time the file is opened, it will be opened in the Index tab.
Following code is working for me:
Help.ShowHelp(this.btnOpenHelpShowTopic, helpProvider1.HelpNamespace, HelpNavigator.Topic, #"/Garden/flowers.htm");

File Path Control

How to put a File path control in VBA front panel? I want the user to be able to select the browse button and select the file path rather than putting up dialog boxes all over the place. I need the user to select three or more file paths.
After re-re-reading your Q, it seams you want to steer away from dialog boxes!Oh well, I was going to say
I could post the hack about using MSDIAG on VBA, that explains
how you can patch your registry to
enable its use under VBA,
without having other MS-VB products
installed... but I rather have you
google that one... you can certainly
understand why.
But you don't want Dialog Boxes... you want controls and buttons: Use listboxes!
To populate your listbox, use the Dir command (using method additem of the listbox).
Two phases for achieving that:
first get the Directories (and prefix a "->" or whatever prior to adding it on the listbox, so that the user understands this is not a file);
then get filenames (you can filter by extension with the arguments of Dir, just as you would in DOS).
Finally, under OnClick and OnDoubleClick of the listbox, you must interpret the listbox default property (Item), check for "->" and use ChDir to change directory and repopulate, or you'll have your file selected.
The write up is sooooooo much more complicated than the code... trust me.
Do you mean VBA for Microsoft Office or just general VBA?
In Office, Application.FileDialog(msoFileDialogOpen).
Otherwise, look at the Win32 API function SHBrowseForFolder (in shell32.dll). You can import it for use into VBA using the Declare Function keywords.
There is not direct VBA function for that. You can decide to combine a form (Access form, or a generic microsoft form) with 2 controls: (1) text box (2) browse button (which will finally use the fileDialog command or a windows API).
Perhaps the browse for folder API from the Microsoft MVPs site would suit:
http://www.mvps.org/access/api/api0002.htm
It uses SHBrowseForFolder mentioned by fwzgekg, and does not return a file dialog, it returns a browsable list of folders.
Is this what you want?
FilePath = Application.GetOpenFilename

Resources