Windows Registry file association menu - windows

I have recently(today) began meddeling with my registry from within Delphi. :)
all is working well and my custom file type now opens with my program, but there are 2 issues i can't solve.
1) I wanted the option to "open with" from all file types so i added
reg := TRegistry.Create;
reg.RootKey := HKEY_CLASSES_ROOT;
reg.LazyWrite := false;
reg.OpenKey('*\OpenWithList\EncryptionSystem', true);
reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"');
reg.CloseKey;
reg.free;
If I look in the registry using regedit it's sure there as it should seem to be but when I right click on a file and select Open With it's not there...
So I then added this
reg.OpenKey('*\shell\Encrypt\command', true);
reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"');
reg.CloseKey;
This does work for every file but the option is right at the top with "open" and "edit".
I kinda want it to appear in a menu subsection like most programs do...
I realised that i needed to play with shellext but i did not understand the structure of how these worked withing the context menu handlers... I'd learnt all I had from reading the registry anyway... I know the name for the shellext appears later after the ".*" but as for the meaning of the big jibberish keys I have no idea.

It looks like the "Open with" menu is not populated by that registry key alone. It's trumped by an extension-specific list stored by Explorer at the following location:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
I'd venture a guess that the list you're adding your application to is only used if Explorer doesn't have anything better to use — so only for files that don't already have their own "Open with" lists defined.
Also, it looks like an "Open with" registry entry is supposed to have a different form from the one you're using. The key should be the name of the EXE file, such as ExcryptionSystem.exe. The default value for that key, if present, should be an empty string. I'm basing this just on what I see in the registry on my own system.
You should take a look at the File Types MSDN article, part of the Introduction to File Associations.

Looking at the registry it looks like it your line should be changed to.
From
reg.OpenKey('*\OpenWithList\EncryptionSystem', true);
reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"')
to
reg.OpenKey('*\OpenWithList\EncryptionSystem.exe', true); //note exe
reg.WriteString('','C:\Program Files\EncryptionSystem\EncryptionSystem.exe "%1"')
Check this first.

On my W7P they're not as referenced. Instead they're at...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

Related

How can I add item in desktop menu/new file (right click on desktop)?

I want to create new TXT file, but for some reason TXT file do not appears anymore when I click with right button on desktop, and go to 'NEW' (list of file types to create).
I saw these instructions somewhere else. They were really useful for me.
To Add an Item in “New” menu:
Type regedit in RUN dialog box and press Enter. Now expand “HKEY_CLASSES_ROOT” key.
Now look for the file type which you want to add in “New” menu, e.g. for adding MP3 file type look for .MP3 key.
Right-click on it and select “New -> Key” and give it name “ShellNew”.
In right-side pane, right-click and select “New -> String Value”. Give it name “NullFile” and press Enter.
Thats it. You’ll immediately get the file type entry in “New” menu.
Detailing:
Go to regedit
Open "HKEY_CLASSES_ROOT"
Find '.txt' and click on it
Check if "(Default)" "Data" value is "textfile", if not, set it to "textfile"
Check if "ShellNew" path exists in '.txt', if not, create it
Check if "NullFile" string value exists in "ShellNew", if not, create it
Find 'textfile' on "HKEY_CLASSES_ROOT" , if not exists, create it and set "(Default)" "Data" value to "Text Document" or other than you prefer
Go to desktop / right mouse click / Refresh to see your new item in 'New' list
Basically 4 things are needed:
.txt path with default value set as 'textfile'
ShellNew path into .txt path
'NullFile' string value into ShellNew with no data
textfile path with default value as the description of file
Try using this post http://www.mediacollege.com/microsoft/windows/extension-change.html.
This should show you how to make a text file.
If this doesn't work you can add it in to the context menu by following these instructions
https://superuser.com/questions/629813/create-new-text-document-option-missing-from-context-menu

VBS - display multple filetypes in save dialog

I got the following code to open the save dialog with one FileType:
Set objDialog = CreateObject("SAFRCFileDlg.FileSave")
objDialog.FileName = "Automatic Generated Presentation"
objDialog.FileType = "PowerPoint 97-2003 Presentation (*.ppt)"
objDialog.OpenFileSaveDlg
How can I add another FileType to the combobox / listbox in the dialog?
I tried to seperate them using '|', using ',', using ';' and more - nothing worked ofcourse.
Is that even possible?
I didnt find anything like that in the internet.
Will appreciate your help.
I've found an interesting article where the author debugs Windows API calls made by the SAFRCFileDlg.FileSave object to find out whether it allows multiple file filters:
Debugging the SAFRCDLG.DLL FileType filter string
The answer is No.

How to Get Submenu in MFC?

I'm trying to get a submenu so that I can make changes to it before it is displayed.
So I created an OnInitMenu() handler for my window. And I had planned to use pMenu->GetMenuItemInfo() to get the submenu.
However, it doesn't appear this will work. In order to locate the menu I want, I must supply the menu command ID (I do not consider it satisfactory to hard code item positions). But menu items that open submenus do not have command IDs. I can get a menu command that exists inside that submenu, but then I still don't have the menu itself.
How can I locate a submenu nested in my main menu, without relying on MF_BYPOSITION?
My solution to this same problem was to create a helper function to search through the menu and return the position based on the name of the menu.
int CEnviroView::FindMenuItem(CMenu* Menu, LPCTSTR MenuName) {
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++) {
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
str.Compare(MenuName) == 0)
return i;
}
return -1;
}
It appears the answer is that you can't. Using command IDs to locate a menu command makes great sense because such code will continue to work as you rearrange menu items. However, menu items that are sub menus simply do not have a command ID.
One approach is to have a known menu command, which you can search for by ID, and then insert new items next to that command. However, you still need the containing menu.
The approach I ended up using resulted from studying the code MFC uses to populate the most recently used file list in the File menu. The general technique is described in the somewhat dated Paul DiLascia's Q & A column from Microsoft Systems Journal.
It would be much simpler to use MFC Command routing that allows you to update menu items?
If this is MDI/SDI application you have it for free if not you will have to implement update mechanism.
Do not handle WM_INITMENU. You should handle WM_INITMENUPOPUP. WM_INITMENUPOPUP delivers pointer to the menu that is just about to popup.
In the handler you can write a code that will allow dialog updating specific menu items using UI update mechanism fo all menus, or you can handle only a change to the specific menu item you have to alter in the handler.
You can use the method GetSubMenu from the class CMenu.
http://msdn.microsoft.com/en-us/library/dtfc356x(v=vs.80).aspx

TYPO3: Change plugin from USER to USER_INT type

I have a working TYPO3 extension. It is attached this wiki page. How can I change the code of this extension so it is of the USER_INT type? I.e. I don't want TYPO3 to cache the output of this plugin, and want TYPO3 to invoke the extension ever time a page that uses the extension, i.e. disable the caching for this extension.
To disable caching for your extension go to your piX/class.tx_XXX_piX.php file and remove the following line (below your class declaration):
var $pi_checkCHash = true;
You also need to add the following line in the main method (below $this->pi_loadLL();):
$this->pi_USER_INT_obj=1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
grunwalski it's the opposite you have to change this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',1);
to this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',0);
The simpliest way to solve your problem is to go back to Extension Maganer, select your extension, choose "Edit in Kickstarter" from the dropdown menu, and then select the corresponding Frontend plugin to edit it's properties.
Check the first checkbox which means that you want your plugins to be rendered as USER_INT cObjects. After that click the View result button, uncheck all custom PHP files (your own code, like modules and plugins) on the right side and click the WRITE button. Please be careful. If you don't uncheck the checkboxes of your own files, they will be overwritten with dummy files.
The correct and comlete way to do this is a combination of the answers of #arturh and #Mehdi Guermazi:
change the last parameter in the addPItoST43() call in ext_localconf.php from 1 to 0
remove the var $pi_checkCHash = true; line from the property definitions in the head of the pi1 class.
add the $this->pi_USER_INT_obj=1; line to the start of the main() function in pi1.
These changes are identical to what you will get when you use the kickstarter method explained in the solution of #bencuss.
When you have created your extension with Kickstarter you also have to go to the file [yourextension]/ext_localconf.php and change this line
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',0);
to this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',1);
Edit the file setup.txt of your extension "myext". Change "USER" into "USER_INT".
plugin.tx_myext = USER_INT
plugin.tx_myxt {
This extension will never be cached.

Save drop-down history in a Firefox Toolbar

I'm doing some testing on Firefox toolbars for the sake of learning and I can't find out any information on how to store the contents of a "search" drop-down inside the user's profile.
Is there any tutorial on how to sort this out?
Since it's taking quite a bit to get an answer I went and investigate it myself.
Here is what I've got now. Not all is clear to me but it works.
Let's assume you have a <textbox> like this, on your .xul:
<textbox id="search_with_history" />
You now have to add some other attributes to enable history.
<textbox id="search_with_history" type="autocomplete"
autocompletesearch="form-history"
autocompletesearchparam="Search-History-Name"
ontextentered="Search_Change(param);"
enablehistory="true"
/>
This gives you the minimum to enable a history on that textbox.
For some reason, and here is where my ignorance shows, the onTextEntered event function has to have the param to it called "param". I tried "event" and it didn't work.
But that alone will not do work by itself. One has to add some Javascript to help with the job.
// This is the interface to store the history
const HistoryObject = Components.classes["#mozilla.org/satchel/form-history;1"]
.getService(
Components.interfaces.nsIFormHistory2 || Components.interfaces.nsIFormHistory
);
// The above line was broken into 4 for clearness.
// If you encounter problems please use only one line.
// This function is the one called upon the event of pressing <enter>
// on the text box
function Search_Change(event) {
var terms = document.getElementById('search_with_history').value;
HistoryObject.addEntry('Search-History-Name', terms);
}
This is the absolute minimum to get a history going on.
Gustavo,
I wanted to do the same thing - I found an answer here on the Mozilla support forums. (Edit: I wanted to save my search history out of interest, not because I wanted to learn how the Firefox toolbars work, as you said.)
Basically, that data is stored in a sqlite database file called formhistory.sqlite (in your Firefox profile directory). You can use the Firefox extension SQLite Manager to retrieve and export the data: https://addons.mozilla.org/firefox/addon/5817
You can export it as a CSV (comma- separated values) file and open it with Excel or other software.
This has the added benefit of also saving the history of data you've entered into other forms/fields on sites, such as the Search field on Google, etc, if this data is of interest to you.
Gustavo's solution is good, but document.getElemenById('search_with_history').value; is missing a 't' in getElementById

Resources