New release of code samples from Microsoft All-In-One Code Framework (2011-6-19)

A new release of Microsoft All-In-One Code Framework is available on June 19th.  We expect that its 14 new code samples would reduce developers’ efforts in solving the following typical programming tasks.

Download address:

Alternatively, you can download the code samples using Sample Browser or Sample Browser Visual Studio extension . They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates.

If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, and read the introduction on our homepage


New Windows Azure Code Samples

We released a set of Windows Azure code samples based on customers’ heatedly requested code sample topics in the official Windows Azure Code Samples Voting Forum.



The sample demonstrates using the startup tasks to install the prerequisites or to modify configuration settings for your environment in Windows Azure.   The code sample is created for answering this code sample request Startup tasks and Internet Information Services (IIS) configuration voted for 27 times.

You can use Startup element to specify tasks to configure your role environment.  Applications that are deployed on Windows Azure usually have a set of prerequisites that must be installed on the host computer. You can use the start-up tasks to install the prerequisites or to modify configuration settings for your environment. Web and worker roles can be configured in this manner.

CSAzureManagementAPI, VBAzureManagementAPI

C# version:
VB version:

Managing hosted services and deployments is another hot Windows Azure sample request.  Twenty developers voted for it. 

The Windows Azure Service Management API is a REST API for managing your services and deployments.  It provides programmatic access to much of the functionality available through the Management Portal. Using the Service Management API, you can manage your storage accounts and hosted services, your service deployments, and your affinity groups.  This code sample shows how to create a new hosted service on Windows Azure using the Windows Azure Service Management API.

CSAzureWebRoleBackendProcessing, VBAzureWebRoleBackendProcessing

C# version:
VB version:

This code sample shows how a web role can be used to perform all of the frontend and backend operations for an application, according to this popular Windows Azure code sample request: Using a web role for both the frontend and backend processing of an application.

Windows Azure provides worker role to perform backend processing.  Generally, a worker role is deployed to one or more separated instances from the web role.  However, sometimes we want to perform backend processing in the same instance of web role for cost saving purpose etc.

This sample shows how to achieve this goal by using startup task in a web role to run a console application in the backend. The backend processor works much similar to a worker role. The difference is that it runs as a startup task in the same instance of the web role.

Please note if a VM crashes both the frontend web role and the backend processor on the VM stop working, and the scalability of the backend processor is coupled with scalability of the web role, which may not be suitable in some scenario.


New Windows Driver Kit (WDK) Code Samples

Thanks to Bart Bartel – a senior Escalation Engineer in Microsoft, we have the first Windows Driver Kit (WDK) code sample published in All-In-One Code Framework.



This code sample demonstrates how to use Virtual Disk Service (VDS) to enumerate and interface with volumes on a system.  When you run the sample application as administrator, it outputs a list of volumes on your system, their properties, and the disk extents that back the volume.  Here is an example output:



New Windows General Code Samples



Produced by Frank Kim – a senior Escalation Engineer in Microsoft, the C++ code sample demonstrates how to obtain and display the security descriptor for various Kernel Objects in Windows, including

  • mailslot
  • service control manager
  • directory
  • event
  • file
  • thread
  • memory mapped file
  • job object
  • desktop
  • printer
  • mutex
  • named pipe
  • process access token
  • process
  • registry key
  • semaphore
  • network share
  • service
  • window station

The sample by default only obtains the Access Allowed Aces (DACLs) and NOT the System Audit Acess (SACLs) although Integrity Aces are SACLs so these will be displayed as well. By default the Security Descriptor is displayed in Security Descriptor Definition Language (SDDL) format. There is a switch to get more detailed information  on the security descriptor.

For example, I build the sample project and get CppCheckSD.exe.  Next, I enter the command "D:\CppCheckSD.exe -d c:\" to see the security descriptor of my C:\ directory:

>>                                     SECURITY INFORMATION                                       >>

object name ........ c:\
object type ........ directory
sd ................. O:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464G:S-1-5-80-9560
length ............. 282

CSExtractAudioFile, VBExtractAudioFile

C# version:
VB version:

The sample demonstrates how to extract and convert audio file formats, which include wav, mp3 and mp4 files.


The sample is used to extract music file formats. We usually play music with Windows Media Player or other music-playing software. If we find our favorite
music clip, we can use the function of this sample to extract it and convert it into another file format. All technology mentioned above is based on Expression Encoder SDK 4.0. When you install Expression Encoder 4.0, you can use Visual Studio 2010 to add a reference to it. In this way, you don't have to install the SDK installation kits individually.

The sample uses Expression Encoder SDK 4 to output *.mp4 or *.wma file. The .mp3 audio format is currently not supported as output format in Expression
Encoder 4.

CSRunProcessAsUser, VBRunProcessAsUser

C# version:
VB version:

The code sample demonstrates how to run a process as a different user.


CSWinFormSaveWebpageToImage, VBWinFormSaveWebpageToImage

C# version:
VB version:

The project illustrates how to generate the thumbnail image for a webpage.

The code sample creates a WebBrowser to retrieve the html code of the target webpage, and uses be WebBrowser.DrawToBitmap method convert the html code to .bmp image. In this code-sample, users can set the image's width, height and browser's width, height, generate an appropriate image.



New Windows Workflow Foundation Code Sample



Consider that there are two such workflow instances:
               start                              start
                  |                                     |
      Receive activity          Receive activity
                  |                                     |
      Receive2 activity       Receive2 activity
                  |                                     |

A WCF request comes to call the second Receive2 activity. Which one should take care of the request? The answer is Correlation. This sample will show you how to correlate two workflow service to work together.



If you have any feedback, please fill out this quick survey or email us: