Visual C++ Express, Microsoft Windows SDK & Windows Vista 64-bit

This article is part of a backup. It was originally posted on Wednesday, February 21. 2007.

The following article describes how to use Visual Studio C++ 2005 Express Edition with the new Microsoft Windows SDK on 64-bit Windows Vista systems. It will, at least for the better part, apply to other Windows Operating systems as well.

Requirements

This article assumes that you have a working installation of Windows Vista 64-bit. Please note that only the Vista Ultimate Edition has 64-bit media included. All other Vista editions contain 32-bit media only. The 64-bit media for those editions can be purchased on the Windows Vista Alternate Media page. MSDN subscribers receive the media automatically.

At this point you should run Windows Update to see if there are any updates for either installation. At the time of writing this, the following important updates were available:

I used the default directories for all installations, but it doesn’t really matter where you install everything, as long as you remember the paths. Now get ready for the messy part!

Include Paths

The paths to include files, libraries and tools of the Windows SDK are not automatically added to the environment or registered with Visual C++ 2005 Express Edition after installation. In order to avoid having to configure them for each individual project, it is recommended that you add them to your Visual Studio default settings. This is accomplished in the following steps:

  • Start Visual C++ 2005 Express Edition.
  • Select Options… from the Tools menu.
  • In the Options dialog box, expand the Projects and Solutions node and select VC++ Directories.
  • Select Executable files from the drop down box on the top right and add the following path: {windowssdk_install_path}\Bin
    e.g. C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin.
  • Select Include files from the drop down box and add the following path: {windowssdk_install_path}\Include
    e.g. C:\Program Files\Microsoft SDKs\Windows\v6.0\Include.
  • Select Library files from the drop down box and add the following path: {windowssdk_install_path}\Lib
    e.g. C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib.

The same steps have to be taken for the include files and libraries in the DirectX SDK:

  • Select Include files from the drop down box and add the following path: {directxsdk_install_path}\Include
    e.g. C:\Program Files (x86)\Microsoft DirectX SDK (February 2007)\Include.
  • Select Library files from the drop down box and add the following path: {directxsdk_install_path}\Lib\x86
    e.g. C:\Program Files (x86)\Microsoft DirectX SDK (February 2007)\Lib\x86.

The two placeholders {windowssdk_install_path} and {directxsdk_install_path} refer to the Windows SDK and DirectX SDK installation directories. Please note that, on your machine they might not be the same as in the examples shown above if you chose to install the SDKs in a directory different from the default, or if your SDKs are a different version. Replace these placeholders with the ones specific to your own installation directories and SDK versions.

Default Libraries

By default, Visual C++ 2005 Express Edition does not have the standard Windows libraries configured. To avoid linker errors when building SDK Sample projects, you should add the standard libraries to the list of additional library dependencies:

  • Navigate to the directory %VSINSTALLDIR%\VC\VCProjectDefaults directory, where %VSINSTALLDIR% stands for the installation directory of Visual C++.
    e.g. C:\Program Files (x86)\Microsoft Visual Studio 8
  • Open the file corewin_express.vsprops in a text editor.
  • Change AdditionalDependencies=”kernel32.lib” in the Tool entry to include all Windows core libraries. Your file should look similar to this:
  1. <?xml version="1.0"?>
  2. <VisualStudioPropertySheet
  3.         ProjectType="Visual C++"
  4.         Version="8.00"
  5.         Name="Core Windows Libraries">
  6.         <Tool
  7.                 Name="VCLinkerTool"
  8.                 AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib" />
  9. </VisualStudioPropertySheet>

The core libraries should now be automatically included for all projects. If you do not wish to use some of these libraries in any of your projects, you can explicitly ignore them in the Ignore Input Library setting of your project’s Properties.

Win32 Application Wizzard

If you are used to create new Windows applications using the project wizzard, you will notice that the application wizzard template for Win32 applications is disabled in Visual C++ Express Edition. It can be enabled again by editing the appropriate settings file:

  • Navigate to the directory %VSINSTALLDIR%\VC\VCWizards\AppWiz\Generic\Application\html\1033.
    e.g. C:\Program Files (x86)\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033
  • Open the file AppSettings.htm in a text editor.
  • In the function InitControls() comment out the following lines:
    1. WIN_APP.disabled = true;
    2. WIN_APP_LABEL.disabled = true;
    3. DLL_APP.disabled = true;
    4. DLL_APP_LABEL.disabled = true;

    Your result should look like this:

    1. //WIN_APP.disabled = true;
    2. //WIN_APP_LABEL.disabled = true;
    3. //DLL_APP.disabled = true;
    4. //DLL_APP_LABEL.disabled = true;

You will also have to modify the script that is used to set up new projects:

  • Navigate to the directory %VSINSTALLDIR%\VC\VCWizards\AppWiz\Generic\Application\scripts\1033.
    e.g. C:\Program Files (x86)\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\scripts\1033
  • Open the file default.js in a text editor.
  • In the function OnFinish() comment out the two lines containing LinkTool.AdditionalDependencies = “kernel32.lib $(NoInherit)”;

DirectX

The DirectX SDK installation should work out of the box and not require any manual intervention. If you are experiencing problems compiling DirectX applications, particularly the DirectX samples in the Windows SDK, make sure that the following settings are correct:

  • In the system environment variables there should be an entry DXSDK_DIR containing the installation directory of the DirectX SDK.
    e.g. C:\Program Files (x86)\Microsoft DirectX SDK (February 2007)

Help Files

The last step is configuring the context sensitive help for the Windows SDK. Again, this has to be done manually for Visual C++ 2005 Express Edition:

  • Start Visual C++ 2005 Express Edition.
  • Press F1 to open the Microsoft Document Explorer.
  • Paste the following address into the URL box and press Enter: ms-help://MS.VSExpressCC.v80/dv_vsexpcc/local/CollectionManagerExpress.htm
  • At the bottom of the page is a list of Collections available for inclusion in VSExpressCC. Select the checkbox for Microsoft Windows SDK.
  • Click the Update VCExpressCC button and confirm the two message boxes.
  • Close the Microsoft Document Explorer and restart Visual C++ Express Edition.
  • Restart Visual C++ 2005 Express Edition and press F1 to open the Microsoft Document Explorer. The context sensitive help should now reconfigure itself to include the Windows SDK documentation.

The context sensitive help for Win32 applications should now be available. Please note that many entries for Windows API functions default to their .NET counterparts. Google often delivers better results when searching for API documentation.

If you painstakingly went through all the steps described in the previous paragraphs, you should now be able to build and test Windows SDK and Direct SDK samples, as well as your own Windows and DirectX based applications. Happy coding!

MCF/ATL/WTL Notes

Visual C++ 2005 Express Edition does not include header files or libraries for MFC, ATL and WTL, and these files are also not included in the Windows SDK. Therefore, many Windows SDK sample projects will fail to build. More information on this issue, including a list of affected sample projects can be found in the Windows SDK Release Notes. The Code Project has an article on using WTL with Visual C++ 2005 Express Edition.

Other Resources

There already is some information on this topic for 32-bit versions of Windows available online. Microsoft has a special page in the Visual Studio Express section, an entry in the MSDN Knowledge Base and another article in Brian Johnson’s Weblog. There is also an article on The Code Project, which attempts to give a conclusive summary.

Getting Started with WPF in Visual C# Express Edition

This article is part of a backup. It was originally posted on Tuesday, February 27. 2007.

Currently, none of the Visual Studio suites have out-of-the-box support for the new Windows Presentation Foundation (WPF) in the .NET Framework 3.0. This article explains what you need to get started with the development of WPF based .NET applications in Visual C# Express (and other Visual Studio Editions).

Requirements

In the following paragraphs it is assumed that you have a working installation of Visual C# 2005 Express Edition and the .NET Framework 3.0 (RTM Release that ships with Vista or the Windows SDK) or newer. In order to add WPF support to Visual C# Express, you also have to have the following:

The .NET Framework 3.0 samples are not required for building WCF/WPF applications, however, they are strongly recommended as they contain a large variety of instructive sample projects. Make sure to select the Samples_All.exe download for the framework samples, which includes all of the other listed downloads. The installer will simply unpack five ZIP files into the Samples folder of your Windows SDK installation. You can unzip these into a folder of your choice.

Features and Limitations

Despite its name, the Visual Studio 2005 extensions for .NET Framework 3.0 also support Visual Basic Express Edition, Visual C# Express Edition, Visual Web Developer Express Edition, Visual Studio Standard Edition, Visual Studio Professional Edition and Visual Studio Team System Editions.

The current release of the extensions (November 2006 CTP), which is, according to Microsoft, also the last release of this form, will add the following features to Visual C# Express Edition:

  1. XAML Intellisense support
  2. Project templates for WCF and WPF
  3. .NET Framework 3.0 SDK documentation integration

Unfortunately, the the visual designer ‘Cider’, which is WPF’s equivalent of the Windows Forms designer, is currently only available in Visual Studio 2005 (Final Release) and cannot be used in any of the Express Editions. This means that you will not be able to edit forms and controls within the development environment by any means other than editing the XAML markup langauge files directly.

Other Resources

Good places to start with WPF programming are Microsoft’s Guided Tour of Windows Presentation Foundation, the Windows Vista Developer Center and the specific sections on the .NET Framework 3.0 Community. MSDN TV hosts a hand full of insightful video tutorials. There also is an extensive amount of information in Visual Studio’s MSDN help.

Despite the lack of support for a visual designer in Visual Studio Express Editions, you might want to visit the Cider Wiki on Channel9 and the WPF Designer ‘Cider’ Forum

If you’re totally new to WPF, you should probably check out Tim Sneath’s Weblog for a selection of great WPF based application examples. And if you’re still not ready for the next hype in software engineering, watch the official WPF Marketing Video.

Using Cobian Backup on Windows with Apple’s Time Capsule

After consistently losing hard drives over the past few years (and plenty of data with it), having daily automatic backups has become an integral part of my home network. While backing up to a local computer is pretty straightforward, trying to accomplish the same thing over a network is often raising some difficulties with the hardware and software involved. Having played around with various USB-storage capable routers, shared directories, mounted network drives and log-on scripts, I have finally arrived at a simple and reliable solution using Apple’s Time Capsule.

Prerequisites

This article assumes that you are using the following equipment:

Setting up the Time Capsule

Configuring the Time Capsule is very easy using the AirPort Utility and consists of just two steps: enabling file sharing and adding an user account.

  1. Start the AirPort Utility and connect to your Time Capsule
  2. Select the Disks page
  3. Select the File Sharing tab
  4. Turn on the Enable file sharing check box
  5. Set the Secure Shared Disks option to With accounts
  6. Click the Configure accounts… button
  7. Add an account Backup with your desired password and give it read/write access
  8. Click Ok, then Update to restart the Time Capsule

airport2airport3airport4

Adding the Backup user account will conveniently create a shared Backup folder in the root of your Time Capsule where the Data directory resides as well.

Configuring Windows

In order to avoid complicated scripts and network mappings, we add a special Windows user account that performs the actual backup jobs. This user will be used :

  1. Open the Control Panel, go to Administrative Tools and start Computer Management
  2. Select the Local Users and Groups node
  3. Click the Action main menu item and select New User…
  4. Configure and create a new user Backup with the same password as in the Time Capsule

user1

To avoid issues with file access permission during backups, add the Backup user to the Backup Operators user group. This will give the backup service the necessary read access to all files on your computer, including those that are protected by custom folder permissions.

Since the Backup user is only intended to be used for the backup software, it should be hidden from the Windows log-on screen. The following steps apply to XP, Vista and Server versions of Windows:

  1. Open the registry editor (Start Menu → Run… → regedit)
  2. Navigate to the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\SpecialAccounts\UserList
  3. Add a new DWORD value named Backup and leave the default value of 0×00000000

Configuring Cobian Backup

Getting Cobian Backup up and running consists of two more steps: setting up the Cobian Backup service to use the Backup account and configuring the target directory for your backup in the backup task options.

The following assumes that you run Cobian Backup as a system service. If you run it as an application, you should reinstall the program as a service.

  1. Open the Control Panel, go to Administrative Tools and start Computer Management
  2. Select the Services node
  3. Right-click the Cobian Backup 9 service and select Properties
  4. Select the Log On tab
  5. Enter the Backup account and corresponding password, and click Ok

service1

You can edit your backup task in Cobian Backup to point to the correct target directory on the Time Capsule. My Time Capsule is called Time-Capsule, so the path to the directory is \\Time-Capsule\Backup\

cobian1

Note on Personal Folders

If simple file sharing is disabled, personal folders, such as Favorites and My Documents are private by default. Unless explicitly added to the directories’ security permissions, neither the Backup Operator nor Administrator accounts have access to them. If you wish to backup any of those folders, you have to give the Backup account permission for read access. In addition to that, if you use the File Attribute Logic in Cobian Backup, you also have to allow write access to file attributes. In Windows XP and later this can be done on the file’s or folder’s Special Permissions dialog by clicking the Advanced button on the Security properties page.

Other Considerations

If you already have backup files in another directory on your Time Capsule, and you did not use User Accounts before, your old backup files will likely no longer be accessible using the new Backup user account. By temporarily switching the Time Capsule access control back to Time Capsule Password on the AirPort Utility’s File Sharing tab, it is possible to copy the old files into the Backup directory. Please note that the Backup directory will then not be located at the root of the Time Capsule, but in an Accounts directory inside the Data directory.

On Mac computers, the Backup directory can be made permanently accessible to backup programs, such as SmartBackup by clicking on the Time Capsule in the Finder, selecting Connect As… with the Backup user name and password and saving the password in the key chain.

Related Resources

Broken SD Card driver on Fujitsu ST503x tablet PCs under Windows XP

The O2 media slot drivers for the Fujitsu ST503x series of tablet PCs (ST5030, ST5030D, ST5031, ST5031D, ST5032, ST5032D) work well with Sony MemoryStick and CompactFlash cards, but appear to be horribly broken for SD cards. Upon inserting SD cards in the slot, symptoms may include:

  • Media cannot be mounted
  • Media can be mounted, but is not accessible
  • System periodically freezes every few seconds
  • Media randomly dismounts or throws file I/O errors

Solution

After trying various drivers for different brands and models of tablet and laptop PCs, the driver for the Fujitsu T42xx series of laptops appears to be working reliably. The driver can be obtained in the Support & Downloads section on the Fujitsu website:

  1. Select Notebooks
  2. Select T Series
  3. Select T4220
  4. Download and install Media Slot V2.16 or newer

Unblocking Elevated Startup Programs in Vista

This article is part of a backup. It was originally posted on Wednesday, March 28. 2007.

Windows Vista significantly changed the way applications are handled when the user logs on. The system now blocks elevations in the user’s logon path, which prevents users from running programs on startup that require administrator privileges. Unfortunately, Vista provides no way of permantently unblocking a startup program. This article will describe a clean and quick workaround to get the same result.

Background

In Windows Versions prior to Release Candidate 1, all programs launched on startup (i.e. from the Startup folder or the Run registry key), and that required elevated permissions to run without being properly set up to run on Vista, generated their own UAC popup window to let users know that these programs had been blocked from execution.

In RC1 and later, Microsoft has changed this behavior into a slightly less annoying version, which displays a single, small balloon message in the notification area of the taskbar, informing users that Windows has blocked some startup programs. Either way, the programs still won’t start, which represents a serious problem to anyone wishing to automatically run non-Vista enhanced software, such as automatic update tools, DynDNS tools or FTP servers.

The correct solution for this issue would be to have software vendors update their applications. However, this is not always possible, as certain products might get updated very rarely, or might no longer be maintained at all. There is currently no way to permantently unblock startup programs in Windows Vista, except for disabling UAC. Fortunately, we can circumvent the startup problems alltogether by taking advantage of the Windows Task Scheduler.

Solution

The trick proprosed in this article is to launch the affected applications through Windows Task Scheduler. It has the ability to launch programs or batch files on system startup with the credentials of a specified user account and with the highest privileges. To automatically launch a non-Vista enhanced application with administrative privileges on Vista, simply perform the following steps:

  1. Remove the program from the Startup folder or the Run registry key
  2. Launch the Task Scheduler
    e.g. Start Menu → All Programs → Accessories → System Tools
  3. From the Actions panel on the right, select Create Task…
  4. Go to the Security Options on the General tab
    1. Select an user account with administrative privileges
    2. Select the radio button Run only when user is logged on
    3. Check the box Run with highest privileges
  5. Go to the Triggers tab and click New…
    1. In Begin the task, select At log on
    2. In the Settings options, select All users
    3. In the Advanced Settings options, check the box Enabled
    4. Click OK to close the dialog
  6. Go to the Actions tab and click New…
    1. For Action, select Start a program
    2. In the Settings options, browse for the Program/Script you want to execute on startup
    3. Click OK to close the dialog
  7. Go to the Settings tab
    1. Check the box Run task as soon as possible after a scheduled start is missed
    2. Uncheck the box Stop the task if it runs longer than
  8. Make any other desired settings
  9. Click OK to save and close the task properties

The specified program will now be automatically launched every time the system restarts and some user logs on. When Task Scheduler launches the program for the very first time, Windows Defender will block it and give you the option to unblock it permanently.

Related Resources

The new blocking behavior of Windows Vista RC1 and later has been originally announced on the UAC Blog on MSDN. Software developers should also read Microsoft’s instructions on how to add Vista support to existing applications, which also explains the rationale for this new startup behavior in Vista.