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: https://1code.codeplex.com/releases/view/68596

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 https://1code.codeplex.com/.

---------------------------------

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.

CSAzureStartupTask

Download: https://code.msdn.microsoft.com/CSAzureStartupTask-ebb574a0

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

Downloads
C# version: https://code.msdn.microsoft.com/CSAzureManagementAPI-609fc31a
VB version: https://code.msdn.microsoft.com/VBAzureManagementAPI-3200a617

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

Downloads
C# version: https://code.msdn.microsoft.com/CSAzureWebRoleBackendProces-d0e501dc
VB version: https://code.msdn.microsoft.com/VBAzureWebRoleBackendProces-5c14157d

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.

CppVDSQueryVolumes

Download: https://code.msdn.microsoft.com/CppVDSQueryVolumes-b2aa1d7f

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:

image

--------------------------------------------------

New Windows General Code Samples

CppCheckSD

Download: https://code.msdn.microsoft.com/CppCheckSD-6bac6d3a

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
08885-3418522649-1831038044-1853292631-2271478464D:PAI(A;;FA;;;BA)(A;OICIIO;GA;;;BA)(A;;FA;;;SY)(A;O
ICIIO;GA;;;SY)(A;OICI;0x1200a9;;;BU)(A;OICIIO;SDGXGWGR;;;AU)(A;;LC;;;AU)S:(ML;OINPIO;NW;;;HI)
length ............. 282

CSExtractAudioFile, VBExtractAudioFile

Downloads
C# version: https://code.msdn.microsoft.com/CSExtractAudioFile-0cfaefd9
VB version: https://code.msdn.microsoft.com/VBExtractAudioFile-64a93bee

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

image

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

Downloads
C# version: https://code.msdn.microsoft.com/CSRunProcessAsUser-e4b10d6f
VB version: https://code.msdn.microsoft.com/VBRunProcessAsUser-ce5eba50

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

image

CSWinFormSaveWebpageToImage, VBWinFormSaveWebpageToImage

Downloads
C# version: https://code.msdn.microsoft.com/CSWinFormSaveWebpageToImage-4dcb7aa6
VB version: https://code.msdn.microsoft.com/VBWinFormSaveWebpageToImage-31115ae9/

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.

image

------------------------------------------------

New Windows Workflow Foundation Code Sample

VBWF4ActivitiesCorrelation

Download: https://code.msdn.microsoft.com/VBWF4ActivitiesCorrelation-3563324c

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.

image

 

If you have any feedback, please fill out this quick survey or email us: onecode@microsoft.com