Windows 7 Sensor and Location platform: What is it? (Part 1/3)

Windows 7 +1One of components Windows 7 is Sensor and Location platform. Sensor and Location is part of Windows 7 which allows to work with various sensors and additional devices for measurement something.

What for it is necessary? Sensors are necessary to make more simple some trivial actions. Especially actually it for owners of laptops, whose life is very dynamical. Imagine, that the ambient sensor which is accessible to all applications is built in the computer and gives the chance to these applications to correct the picture depending on illumination. Other example the sensor of GPS-coordinates can be. In this case applications can be adjusted that depend on district where you are at present. For example, applications can display the information on weather for that city where you are. It is possible to see a considerable quantity of examples, all depends on imagination and concrete cases. Applications which change the behavior depending on external conditions are allocated in a separate class of applications and are named context-aware applications.

There can be a question – “and what, actually, has changed?”, “why it could not be made earlier?”. The answer is simple – earlier these scenarios also could be implemented. However, to make it was not so simply. Actually, work with external sensors was exchange of information through COM-port and each sensor had specific API. For this reason it was very heavy to organise any universal program interface with which it was possible to work simultaneously from several applications.

This problem is solved by Sensor and Location library. With its help it is possible to access to various sensors and to receive from them the information in uniform style for all. It is important, that this problem has been solved at level of operational system. It can give a new push for development of context-aware applications. Further the diagramme of structure of objects for work with sensors is displayed. In following parts we will consider it more in detail.

For sensor connection to Sensor and Location platform in Windows 7 it is necessary to implement for it the driver and simple classes-wrappers on.NET for work with this sensor.

Certainly, in the near future end users hardly can feel power of all this platform to the full. For this purpose it is needed some time that developers of hardware could develop in the hardware platforms some sensors hardware platforms. However, to us, developers, it is possible to start to prepare for it already today. Therefore further I plan to tell about how to work with Sensor and Location platform in a context of business applications.

Work with the taskbar of Windows 7 in WPF applications

Windows 7 +1Recently I have published a series of articles that has been devoted to possibilities of Windows 7 for developers to work with the task panel. I have received a large quantity of responses for this time. Thanks you very much for it. That is interesting, questions were absolutely various subjects. However, the most part of questions was on a theme of use of similar functionality in WPF applications. Really, in the majority of examples I have lost sight WPF applications. I will try to compensate this defect here.

Really, use of these possibilities in WPF applications not strongly differs from their implementation in WinForms. As is known, for use of possibilities of the task panel of Windows 7 we used WindowsFormsExtensions static class in which to contain extension-methods for Form class (form representation in Windows Forms). Unfortunately, in.NET Interop Sample Library there is no have similar class for WPF applications. However it is completely not difficult to create it independently.

If to look at WindowsFormsExtensions class it becomes clear, that all calls are forwarded to Windows7Taskbar class which for form identification is used Handle of window. In a case with Windows Forms the form has property Handle which returns the necessary value. The first task is to receive handle of WPF window. Unfortunately, WPF windows do not have Handle property. However, it is possible to take advantage of WindowInteropHelper class and to receive this information. For this purpose I have made one more method which returns Handle of WPF-window.

private static IntPtr GetWindowHandle(Window window)


    return (new WindowInteropHelper(window)).Handle;


Further in all extension methods it is necessary to change parametre type (type to which it is applied extension method) from Form to Window. After that the majority of possibilities are already accessible to WPF-applications.

Other problem at work with the task panel of Windows 7 is that in some situations it is required to intercept Windows messages which come to a current window. In Windows Forms for these purposes it was possible to override WndProc method and in it to catch all necessary messages.

protected override void WndProc(ref Message m)


    if (m.Msg == Windows7Taskbar.TaskbarButtonCreatedMessage)


        // ...



    base.WndProc(ref m);


Unfortunately, for WPF windows of such method is not present. However, in WPF application it is possible to take advantage of HwndSource object and to add interception of Windows messages through it.

private void Window_Loaded(object sender, RoutedEventArgs e)


    HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).AddHook(WndProc);



private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)




        // ...


    return IntPtr.Zero;


In other the usage of possibilities of the task panel of Windows 7 in WPF applications is implemented similarly Windows Forms.

Sample applications:

Integration of your data sources with Windows 7 Federated Search

Windows 7 +1

How often you should search for the various information? Most likely it occurs every day. It is important, that an information search problem not trivial. Also the information can is in various sources – in files, in e-mail messages, in documents etc. Not the secret, that most part of an information is in a network – local and global.

Windows Search which allows to search easily and conveniently on the basis of indexes has been developed in Windows Vista. In Windows 7 a theme of search has found the continuation and in new OS there was additional tool – Windows 7 Federated Search.

Windows 7 Federated SearchWindows 7 Federated Search is a tool which allows to search of information in a network within Windows Explorer. As a data source in this case can act anything you like – a corporate site, Internet shop, Internet auctions etc.

Difference between federated search and Windows Search consists that mechanisms of federated search do not index data sources, and simply call to them with the request to execute search query. Federated search is focused on the distributed remote sources of an information. Indexation of remote sources can be inefficient and lead to the excessive expense of the Internet traffic. For this reason the approach at which the task of processing of search query is assigned to a remote source. Thus, there is a possibility to connect all necessary remote sources and to search in them not leaving from Windows Explorer.

Despite all convenience of such search, implementation of the search provider is very simple. Federated search in Windows 7 is based on OpenSearch 1.1 standard, and works as follows. For search execution, the Windows 7 will call to the external web service constructed on the basis of the REST-approach. It means, that search query, and also other data necessary for search, are transferred in URI at the calling to this web service. Web-service on the basis of these data should execute search in the data source and will return result in RSS or AtomPub format. After that Windows 7 will present results of search from the received data in the form of files and will display to their user.

For addition of own search provider in Windows 7 it is necessary to create a file of the description of this provider. The format of this file is based on XML and contains the information on the given search service, including URI format for the calling to a web-service.


Thus, for implementation of own provider of federated search in Windows 7 it is necessary to execute two simple actions – to create REST-service for information search and to make for it a description file.

Let’s consider process of creation of the search provider on a following example. There is a list of books with the description, the author and other information. In this case this list contains in XML file (for a demonstration example). As a data source it is possible to use anything you like. Let’s make the search provider for this list.

The file of the description of a search provider represents a XML-file and has “.osdx” extension. This file has the following structure.

<?xml version="1.0" encoding="utf-8" ?>

<OpenSearchDescription xmlns="">

    <ShortName>Federated Search sample provider</ShortName>

    <Url type="application/rss+xml" template="


In Url section of this file the template of the address which will be used at the call to web service is set. It is visible, that this address can assume absolutely various representation. In the address template some sections in which values will be substituted are used. The main section is a “searchTerms” section. In this section the line for search will be substituted. Federated search in Windows 7 obtains data page by page, therefore there are sections “count” and “startIndex” which set the size and page number. It is necessary for, that Windows could receive the first results of search, display their to user, and then work with other elements.

<?xml version="1.0" encoding="utf-8" ?>

<OpenSearchDescription xmlns="">

    <ShortName>Federated Search sample provider</ShortName>

<Url type="application/rss+xml" template="http://localhost:8731/


The last, that it is necessary to make is to create service which will carry out search. In this case there is no binding to concrete technology and the only requirement – service should return result in RSS/Atom format. It is clear, that service can be constructed on absolutely various platforms and technologies. For these purposes the best choice – the usage of possibilities of WCF for creation of REST-services. A lot of attention is already given construction of similar services, therefore I will not stop in detail on it, and I will describe only key steps.

The first, that it is necessary to make is to define the contract. At the contract there will be two operations – execution of search and generating of the detailed information.




public interface ISearchProvider



    [WebGet(UriTemplate = "search/{searchTerms}/*")]

    SyndicationFeedFormatter Search(string searchTerms);



    [WebGet(UriTemplate = "details/{id}")]

    Stream Description(string id); 


The most important thing, on what it is necessary to pay attention during this moment – definition of URI template. Apparently in this case the “search/{searchTerms}/*” template completely corresponds to that has been defined in a description file.

It is necessary to implement this service only. At implementation it is necessary to consider the specified parametres at the call to service (searchTerms, start, count) and to divide search result into pages if it is necessary. For this purpose it is possible to use LINQ methods – Take/Skip. Thus, service implementation will look as follows.

public class SearchProvider : ISearchProvider


    public SyndicationFeedFormatter Search(string searchTerms)


        int count;

        int startIndex;


        int.TryParse(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters.Get("count"), out count);

        int.TryParse(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters.Get("start"), out startIndex);



        var result = SearchBooks(searchTerms);


        if (count > 0)


            if (startIndex >= 0)


                result = result.Skip(count * (startIndex - 1)).Take(count);




                result = result.Take(count);





        return new Rss20FeedFormatter(

            new SyndicationFeed("Federated search sample", String.Empty, null,

                from item in result

                select new SyndicationItem(item.Element(XName.Get("name")).Value,


                    new Uri(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri.ToString() + @"/details/" + item.Element(XName.Get("id")).Value))


                        PublishDate = DateTimeOffset.Parse(item.Element(XName.Get("date")).Value),






Also at service there are methods for display of the detailed information and search execution. At desire it is possible to download an example and to look their implementation there.

After service is ready and started, it is necessary to open a file of the description of service (.osdx) in Windows and to agree with offer to add the search provider. After that this provider will appear in the list of search providers.

Add Search Connector image

Now, when web service works and also the provider of search is successfully added, it is possible to search on a network resource directly from Windows Explorer.

Windows 7 Federated Search sample provider

Apparently, implementation of the search provider for Windows 7 Federated Search is very simple. However, it can make use of your data much more conveniently and easier. One of the most successful examples of using of federated search in external sources is the search provider for corporate sites on the basis of Sharepoint. Why and to us not to implement similar functionality for our applications?

Sample application:

Change of the background image on the logon screen in Windows 7

1 As it has been announced earlier, in new operational system Windows 7 it is possible to easily change a background of a logon screen. For this purpose it is not required to change resources in executable files or to carry out still any special actions. Process of changing of the image is very simple and can be executed without use of additional tools. This functionality is accessible and correctly works since 7057 build.

To change a background on the logon screen it is necessary to do following steps.

  1. To open the registry editor and to find section “HKEY_LOCAL_MACHINE –> Software –> Microsoft –> Windows –> CurrentVersion –> Authentication –> LogonUI –> Background”. In this section there is a special key “OEMBackground” (DWORD type). Value “1” herein says that it is necessary to use special appearance of the logon screen. If the key does not exist, he can be created manually.
  2. To be convinced, that there is folder “%windir%\system32\oobe\info\backgrounds”. Here Windows 7 will search for background images for the logon screen. If this folder does not exist, she is necessary for creating.
  3. To put in this folder all necessary images. For each screen resolution it is necessary to put the image in this folder with a specific name. If the image with the necessary name is not found, file backgroundDefault.jpg will be used. It is important, that each image should be no more than 256 KB, differently it will be ignored. The list of files which are necessary for putting in this folder:
    1. backgroundDefault.jpg
    2. background768×1280.jpg  (0.6)
    3. background900×1440.jpg  (0.625)
    4. background960×1280.jpg  (0.75)
    5. background1024×1280.jpg (0.8)
    6. background1280×1024.jpg (1.25)
    7. background1024×768.jpg  (1.33)
    8. background1280×960.jpg  (1.33)
    9. background1600×1200.jpg (1.33)
    10. background1440×900.jpg  (1.6)
    11. background1920×1200.jpg (1.6)
    12. background1280×768.jpg  (1.66)
    13. background1360×768.jpg  (1.770833)
  4. For display of changes there is no necessity to reboot. It is enough to lock Windows (Win + L) or to leave a current session (Log off).

Also it is possible to take advantage of 3rd-party utilities. One of such utilities – Tweaks Logon Changer for Windows 7. This utility will execute all necessary changes in the system registry, and also will compress the image till the necessary sizes and will put in the necessary folder.

Tweaks Logon Changer for Windows 7

Animation of switching of tasks in Windows 7

Windows 7 +1Among an users of Windows there are such people to whom smooth animations are not necessary at switching of windows etc. It is important for these users is speed of work and convenience. In a word, that is necessary for them – the responsible user interface. More recently we communicated with such user by e-mail. Its problem consisted that it is necessary to wait few time before he will see a preview window for the application at hovering on an application icon in the task panel. For this reason I have decided to write pair of tips for such category of users.

Acceleration of animation of showing of a preview window

Situation: At hovering on a icon of the application the preview window appears with a delay.

How to accelerate animation:

  1. We start the registry editor (Start –> Run –> regedit)
  2. We find key HKEY_CURRENT_USER –> Control Panel –> Mouse
  3. Herein we find value MouseHoverTime
  4. We correct this value from 400 to 50 (time of a delay of animation in milliseconds)
  5. Reboot

Switching-off an animation when maximize/minimize of window

Situation: At minimize/maximize of windows there is an animation which can stir in work. If it is fair for your case it can be switched-off.

Animation switching-off:

  1. We open the control panel (Control Panel)
  2. We open section System and Security, then subsection System
  3. In the left side of a window we choose item Advnced system settings
  4. In the appeared window in Advanced tab, in Performance group we press Settings button
  5. In the appeared window we switch off Animate windows when minimizing and maximizing option 

Microsoft Sync Framework 2.0 CTP2

Today next preview version of Sync Framework became accessible.

Version Sync Framework v.2 CTP2 became accessible on June, 4th, 2009. Main features of this version:

  • New database providers
  • Custom filters
  • Improved conflict handling
  • Data conversion between providers
  • Change application service

All new features are interesting that them to look.

Microsoft Download Center:

Windows Mobile 6.5 SDK is accessible to download

Windows Mobile 6.5Today it became accessible SDK to develop for Windows Mobile 6.5. This pack includes the documentation, examples, header files and libraries (for native), tools for Visual Studio and images of emulators. Emulator’s versions are accessible:

  • Windows Mobile 6.5 Professional Square Emulator
  • Windows Mobile 6.5 Professional QVGA Emulator
  • Windows Mobile 6.5 Professional WQVGA Emulator
  • Windows Mobile 6.5 Professional VGA Emulator
  • Windows Mobile 6.5 Professional WVGA Emulator
  • Windows Mobile 6.5 Standard Square Emulator
  • Windows Mobile 6.5 Standard QVGA Emulator

The following locales is accessible to these emulators:

  • 0804 CHS Chinese Simplified
  • 0409 USA English
  • 0407 GER German
  • 040c FRA French
  • 0410 ITA Italian
  • 0c0a ESN Spanish

One of important features of Winodws Mobile 6.5 SDK is Windows Mobile 6.5 touch gesture framework. By means of this component and gesture APIs it is possible to operate the application by means of gestures.

Hasten to download!

Download link:

Give green light to your applications together with Windows 7!

Windows 7 +1 Is your applications are completely compatible with Windows 7 and Windows Server 2008 R2? You can outstrip the competitors, having checked up your applications on compatibility with Windows 7 already today. If your company is ISV you can be helped by a resource.

On this resource you can be registered in the program “Green light” and specify the reference to your application. In this case you receive the necessary information, toolkit and resources for check of compatibility of your applications with Windows 7. If your application is already compatible with Windows Vista or Windows Server 2008 check of compatibility with new operational systems will be very easy.

After check of compatibility of your applications with Windows 7 you can inform this information to your clients and let to them know, that you it is the best than all competitors. As one of the first ISV registered in the program, you will get priority access to marketing materials, templates of messages and the other documents, called to help you to inform about your application to your clients.

Green light program’s site:

Register link:

Windows 7 programming: Taskbar. Part 10 (final part) – JumpLists.

Windows 7 +1One of the major features of the task panel of Windows 7 are Jump Lists. Jump lists are displayed if to select an application icon in the task panel and to press the right button of the mouse. If the application uses functionality of JumpLists, then except standard actions (pin, close) there will be some more additional actions which facilitate our daily work.

This functionality of the task panel various appendices actively use. For example, Windows Media Player displays switching options for play lists. Internet Explorer and Windows Explorer contain in jump lists with references to last places where you came. Windows Live Messanger displays options of switching of a state.

WLM's jump list

In jump list there can be some various types of elements: tasks, references to last open documents and references to constant documents. Besides, these items can be pinned. Such elements will not disappear from jump list in due course. It is convenient, for example, if we often work with the same document. Schematically jump list it is possible to present as follows.

Actually, each item in jump list represents the reference to the program or a file. So, for example, we can start the calculator, or any document of the some format. Unfortunately, we do not have possibility directly to intercept event of pressing item in jump list. Each time when we choose the item, it will be started a new copy of the application. It is so because jump list it is possible to cause even then when the application is not started.  In this case it should be pinned on the task panel. For example, in a following drawing it is visible, that Internet Explorer at present it is not started, but jump list we can open.

So, let’s look how similar functionality can be implemented in our applications. For work with jump list we need to use the object of type JumpListManager which is a part of .NET Interop Sample Library. To create it it is necessary at the moment of creation of the button of our application on the task panel. For these purposes it is possible to override WndProc method as follows.

protected override void WndProc(ref Message m)


    if (m.Msg == Windows7Taskbar.TaskbarButtonCreatedMessage)


        _jumpListManager = WindowsFormsExtensions.CreateJumpListManager(this);

        _jumpListManager.UserRemovedItems += (o, e) =>


            e.CancelCurrentOperation = false;



        // add items





    base.WndProc(ref m);


Pay attention to a call of Refresh method after creation of object JumpListManager. The call of this method is necessary for updating of items in jump list. Also obligatory action is the subscription to UserRemovedItems event. It is executed when attempt of removal of out-of-date items from jump list is made. Let’s now try add new items in jump list. For these purposes there are classes-wrappers and the necessary methods at object JumpListManager.

The most simple type of items in jump list – tasks. The tasks there can be a start of the external application or our application with any parametres. In WLM in the form of tasks switching of a state of the user is implemented. For task creation in jump list AddUserTask method is used.

_jumpListManager.AddUserTask(new ShellLink


    Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "calc.exe"),

    Title = "Calculator",

    Category = "Applications",

    IconLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "calc.exe"),

    IconIndex = 0


As we see, the new object of type ShellLink in which the way to the application is transferred, heading and a icon here is created. I have added in the application two tasks and have the following result.

Other variant of filling jump list – references to documents which have been loaded earlier.  For these purposes I have created some text files with extension “.myapp” and I have associated this type of files with the application. Whether at an application launch I check the name of a file as parametre is transferred at an application launch. If the name is set, I read out this file and I add it in the list before the loaded files. For these purposes there is AddToRecent method.

if (File.Exists(Environment.GetCommandLineArgs().Skip(1).FirstOrDefault() ?? String.Empty) == true)


    _jumpListManager.AddToRecent(Environment.GetCommandLineArgs().Skip(1).FirstOrDefault() ?? String.Empty);


Now from Windows Explorer I will open these files. My demonstration application (if we correctly associated the given type of files with the application) will be started thus. Thus by a call jump list I will see, that in a category “Recent” there were references to earlier open files.

I can pin those items with which I work more often. In this case I can quickly open the documents necessary to me via jump list.

Other way of placing of items  in jump list – creation of references to constant documents/programs. In this case we also can group these items into categories.  For these purposes there is AddCustomDestination method.

_jumpListManager.AddCustomDestination(new ShellLink


    Path = @"about.txt",

    Title = "About",

    Category = "My application",

    IconLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "shell32.dll"),

    IconIndex = 11


I have added some such references in jump list and I have following result.

In this drawing it is visible, that there were two additional groups with references inside.

Remarkable feature of jump list is that its contents also are accessible in the "Start" menu. So, for example, if we actively use this functionality it it is possible to be used and from the starting menu.


Thus we can use additional functionality which gives us the task panel of Windows 7 for much as possible comfortable work of the user.

Sample application:


On it I finish a series of articles devoted to programming of the task panel for Windows 7. I hope this information it will appear useful to you and your applications. I wish to notice especially, that implementation of possibilities of the task panel of Windows 7 for your applications will not demand many efforts, but the result will not keep itself waiting long – will communicate with your application much more pleasantly and more conveniently.

Good luck to you in development of your Windows 7 applications!