How to programmatically get windows search history? - c++

How to get the windows search history and use it in my program? For example I write ".doc" in windows search bar. Now I want in my program to find out from somewhere, that I searched for ".doc" in my system (not web).

I don't know if there's an API for it, but if you do a Windows search for an unlikely string, say "zxcvbnm", then search the registry for it, then on XP you can see it under one of the folders in:
HKEY_CURRENT_USER\Software\Microsoft\Search\ACMru
along with the rest of your recent search strings. I imagine this registry location may change between Windows versions though.
If you're targetting Windows 7 then this MSDN article looks like a good starting point.

Related

SAPI5 voices / using 32bit voices

After spending a whole lot of time on searching the web I think it's time to ask.
I'm trying to implement some text to speech with SAPI5 in C++.
The only available 64bit voice is Anna. With Anna everything is fine, but I also need a german voice. So I found Hedda(Microsoft) and Steffi(Realspeak).
I already feel like implementing some dating service.
Neither Hedda nor Steffi are added to the registry. So both of them are not detected by SAPI while it checks "HKLM\SOFTWARE\Microsoft\Speech\Voices" to get the required tokens to select voices.
I also tried to change the registry paths to ...\SOFTWARE\Wow6432Node... to use the 32bit voices, but no success.
Does anybody know how to use Hedda or Steffi with Sapi?
Is there any way to use the 32bit voices?
Hope anyone can help.
Thanks in advance.
You can use 32 bit voices if you build a 32 bit program, and have 32 bit voices installed to the registry correctly. I describe how to do this registry hack over here. Basically, you just move things around in the registry. The quickest way to accomplish this is to install all of the voices that you want, and then use RegEdit to export those specific registries for where your speech platform voices are.
Then open the registry files with a text editor and replace "Speech Server\v11.0\Voices" with "Speech\Voices"
and replace "Speech Server\v11.0\Voices" with "Speech\Voices". Save off the registry files and then run them to add to your registry.
You should be able to test your new voices in your normal text to speech dialog that windows provides. If however you're on a 64 bit system and you want to test 32 bit voices (because you're building a 32 bit program) you'll have to open the windows speech to text dialog with either
C:\Windows\SysWOW64\Speech\SpeechUX\sapi.cpl
for 32 bit voices I believe and
C:\Windows\System32\Speech\SpeechUX\sapi.cpl
for 64 bit systems voices.
As contradictory as that seems.
Well, editing the registry did the job.
After copying the registry entrys from "\Speech Server\v11.0..." to "\Speech..." (see Lesley Gushurst) and reinstalling SDK, Runtime and voice, voice-"Hedda" can be used on 64bit system with 64 bit application.
Thanks for your help.

App Shortcut without pinning to Start Screen in Windows 8 using C++

Our company has an installer written in C++ that creates program shortcuts using IShellLink as described in:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776891%28v=vs.85%29.aspx
On Windows 8 all shortcuts created in the Start Menu will also show as titles on the Start Screen. What we're looking to do is programmically control which icons are shown on the Start Screen. In the following article it describes the option "System.AppUserModel.StartPinOption" as:
To create add an app shortcut without pinning it to the Start screen
view, you can set the following property on the shortcut:
System.AppUserModel.StartPinOption = 1. The symbolic name for 1 is
APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL.
http://msdn.microsoft.com/en-us/library/windows/desktop/jj673981%28v=vs.85%29.aspx
This appears to be possible using the Windows Installer, however I haven't found a way to accomplish the same functionality programmatically in C++ given our context.
If anyone has any information about this, or an example of some sort, it would be much appreciated.
One thing I found was that "..NewInstall" literally means that. User customizations to the tiles seem to be retained even after you delete/update the .lnk files. This is probably a good thing as updates won't reset the user's environment, but it does mean that I needed to use fresh installs of Windows 8 during testing. I used a VM box to minimize the pain. At least I don't know how to delete the properties once set from within the environment.

How can I find out version of MSWord on computer?

Can anybody help, please. How can I find out version of msword installed on computer? If there is few versions of it, find out that version which open '.doc' by default. Can anybody suggest some C++ functions or algorithm for this task? Sorry for bad english :( Thank you for help.
you can read the registry entry from the path.
for.....
Office 2003 = 11
Office 2007 = 12
Office 2010 = 14
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\AccessNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\ExcelNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\OutlookNameVersion
HKLM\Software\Microsoft\Office\12.0\Word\Registration{-------------}\PowerPointNameVersion
If I want to know what version of Word, I look at the registry key HKEY_CLASSES_ROOT\Word.Application\CurVer
It will give you a ProgId like: "Word.Application.14", "Word.Application.12", or "Word.Application.11" for Office 2010, 2007, and 2003 respectively. The part to the right of the last "." gives the version. If you look at "Word.Document", it won't always give the correct answer because there are feature packs that can be installed that will allow an older version of Word to read a new version of Word document. These feature packs update some registry settings for Word.Document, but they leave Word.Application alone.
Please don't go rummaging through the registry when there are APIs available. Using the appropriate APIs will help make sure your test works for all versions of Windows and Word.
To find out which executable is registered to handle a certain file type (like .doc), use AssocQueryString. Once you have the path to the executable, you can check its version number using GetFileVersionInfo and VerQueryValue.
If you just want to find out which versions are installed (regardless of which application is associated with .doc), you can probably query Windows Installer. Check out MsiEnumProductsEx and MsiGetProductInfo.
There's probably also a way to query for this stuff using WMI.

C++: How-to create a simple program for moving folders

I want to make a program that moves certain named folders (and all files contained) from directory A to directory B. It was suggested to code in C++. So I was wondering if anyone knew of a simple way to do this, if they could give me a link, and if anyone know's where it's possible to set the directories as variables that can be loaded from a text file. I'm asking this question, because I want to basically have all my program settings and whatnot from the appdata folder since I move between computers alot, be easily transferable.
settings.txt (This is an example of what I mean.)
fldrget = (Folder Name)
fldrdir = (Path to Folder)
fldrplc = (Folder Destination)
Would creating an xml document be a better idea as far as the txt document goes?
Additional Information: OS: Windows(XP, Vista, 7) and I'd like to make this a GUI, but as I'm not familiar with any C language, I'll settle for basics first if anyone can give me a push in the right direction.
Can you provide a bit more information? Are you wanting to write a console application or a GUI? What platform are you targeting? You could use the Win32 API, Boost, Qt, Wx, or a number of others.
You may want to look into using PowerShell. It is much more friendly for a new comer and built-in to Windows 7 and freely available for Windows XP. Just do a google search for moving a directory using PowerShell to get started

How to write a shell extension in C++?

This seemed like a common question but after doing some searching, I wasn't really able to find my answers. There is an article on this here:
http://www.codeproject.com/KB/shell/shellextguide1.aspx
But it's for a very old version of Visual Studio. I'm using VS 2008, so the instructions and interfaces don't seem to match what I'm seeing.
I want to create a simple shell extension using C++ that creates a context menu for files with extension .GZ. When right clicking on these files, I should be able to click my context menu item and have a callback in code to do some sort of operation on that file.
Other context menu items would do things like spawn modless dialogs to accept user input before executing some action.
From what I've seen, ATL is used for this but I have never used ATL, so all of the object types and interfaces are very confusing to me. It wouldn't be so bad if I had a proper tutorial or documentation to read.
Can anyone help me out? Isn't there some sort of tutorial out there that isn't 10 years old?
I can't tell you exactly how to write a shell extension, but I will provide a number of tips. Writing a Shell Extension offers some significant advantages over the much simpler “registry-only” method:
With a Shell Extension, you can dynamically create a context menu item (or submenu) that is more relevant to the selected file(s). For example, if you are writing a Shell Extension for zip files, it is possible to create a submenu within the context menu that shows the entire contents of the zip.
You can handle multiple files simultaneously, which may be more beneficial not just for performance purposes but also so that you can work out what to do based on the selection as a whole rather than just for each file.
Some of the downfalls to Shell Extensions are:
Substantially increased complexity. Be prepared to spend a lot of effort on this to get it working. Have a home-espresso machine installed next to your computer and/or hire someone to make you coffee.
Substantially increased difficulty in debugging. Ditto about coffee.
It's difficult to write a Shell Extension because they can be very hard to debug.
Shell Extensions are loaded by the explorer.exe process, and without specific configuration of Explorer, you need to force-quit the explorer.exe process so that you can install a newer version of your Shell Extension. There is a way to get Explorer to unload DLLs that it is no longer using, but you should only do this on a development machine and not on a deployment target:
In RegEdit, browse to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
Add a new DWORD key called “AlwaysUnloadDLL” and set its value to 1.
Restart explorer.
This works most of the time, but there may still be times where you need to close Explorer because the Shell Extension was not unloaded.
Keep in mind that your Shell Extension may be loaded by other applications, for example, if you right-click on a file with an applications “open file” dialog, then your Shell Extension will be loaded into that application, and not Explorer.
If your Shell Extension causes a runtime error, quite often the result will simply be that your context menu item does not show, very rarely will you be told that your Shell Extension failed to load or that it caused a runtime error.
Configuration can be hard, even with an installation, registry data needs to be created in several places, and depending where you want your context menu to show, the places in the registry may differ between different versions of Windows.
What you'll need to do:
Visual Studio offers some shortcuts to creating Shell Extensions, but basically you'll need to create a COM DLL. A Shell Extension for context menu items must implement both the IContextMenu interface and the IShellExtInit interface.
In the IShellExtInit::Initialize() method, you can obtain the selected files from the IDataObject parameter. From memory, the data is in “Drag-n-Drop” format, so you need to get an HDROP handle from the IDataObject and query the files from there (this is from memory, it may actually be different than as I described here, so proceed with caution).
Once your DLL is ready to be “installed”, you must copy it somewhere, and then run regsvr32 to make sure it is registered.
Follow this guide to know where to put registry keys.
There may be issues with 64-bit Windows, if you build a 32-bit DLL it may not load in 64-bit Explorer… so keep this in mind if you are having trouble with 64-bit Windows.
Your DLL will actually have two GUIDs associated with it. I can't remember exactly how it works, but one GUID refers to the DLL itself and the other refers to the actual Shell Extension. Make sure you use the GUID of the actual Shell Extension when creating keys in the registry where a GUID is required.
All things considered… (tl;dr)
Weigh up the costs of whether a Shell Extension is worth it. If you want to create menu items dynamically based on the selected files, then a Shell Extension may be the only way. If you want to handle all files simultaneously then you'll probably need a Shell Extension as well.
An alternative to the context menu method, could be to have a drag-n-drop target on the user's desktop or something. Explore other ways that you could have the user submit your files to your application, because a Shell Extension is often far more effort than it is worth. I found this out the hard way and I think everyone else has too.