Wednesday, October 06, 2010
I often get confused about the different types of C++ casts:
- dynamic_cast can be used for "upcasting" or "downcasting"
- static_cast
- static_cast conversions are not as safe as dynamic_cast conversions, because static_cast does no run-time type check, while dynamic_cast does.
- A dynamic_cast to an ambiguous pointer will fail, while a static_cast returns as if nothing were wrong; this can be dangerous.
- Although dynamic_cast conversions are safer, dynamic_cast only works on pointers or references, and the run-time type check is an overhead. (http://msdn.microsoft.com/en-us/library/5f6c9f8h%28v=VS.100%29.aspx)
- reinterpret_cast
%SystemRoot%\Downloaded Program Files\TransferMgr.exe
See
Thursday, September 30, 2010
If you cannot ping a Windows 7 box, don't just disable the Windows Firewall. See the following page describing how to enable the included ICMP Echo rule in the Windows Firewall:
http://www.fixya.com/support/r5359816-allow_ping_icmp_echo_request_windows_7
Note that I shut down the Windows Firewall service (net stop mpssvc) and this did not "re-enable" ping. I had to add the firewall rule. There may be another solution, but this solved my problem.
Rob
If you have older VMware Workstation disk images (vmdk files) that are split into multiple parts, you can consolidate them into a single disk image from the command prompt:
vmware-vdiskmanager -r MyVirtualMachineDisk.vmdk -t 0 SingleDiskFile.vmdk
The "-t 0" means "single growable virtual disk". If you prefer to preallocate all the storage for the disk, use "-t 2" instead, which means "preallocated virtual disk." You can view more options by running the vmware-vdiskmanager command with no parameters. It will show you what options are available.
I found this solution at http://ubuntuforums.org/showthread.php?t=740914
Rob
Monday, September 27, 2010
By default, SQL Server Management Studio (SSMS) will not let you save changes to the designs of your tables. When you attempt to do so, it wants you to drop and re-create the table. You will typically see a dialog similar to the following:

However, SSMS will actually let you perform such a change without have to drop the table and re-create it. To enable this feature, you need to select Tools / Options from the Menu. Then, navigate to Designers / Table and Database Designers and uncheck the option to "Prevent saving changes that require table re-creation".

Now click the OK button and try saving your table design changes. Voila!
I owe a big thanks to my friend Jack for teaching me this trick. It has saved me a lot of grief!
Friday, September 24, 2010
When you right-click on your WPF project in Visual Studio 2010 (VS2010) and select Add / New Item... / Text File, the "Build Action" on this file is automatically set to "Resource." So, when you ship your application, this text file will be embedded within it. If this was simply meant to be a readme file for your own benefit, you may not want it embedded in your app. In this case, click on the text file in Solution Explorer (or Solution Navigator), go to the Properties window, and change "Build Action" from "Resource" to "None."
Rob
Sunday, September 19, 2010
If you have the Sysinternals SDelete.exe program on your system and would like to be able to right-click on a file or directory in Windows Explorer and have it securely delete that data, then I have just the shell extension for you. Download the SDelete.inf file, below, and securely delete away!
EDIT: I discovered that files and directories with the read-only attribute set on them will not be deleted, so make sure that you remove this attribute before running the SDelete command.
Please let me know if you have any problems with this.
Thanks!
Rob
Right-click and select "Save As" to download SDelete.inf here
Friday, September 17, 2010
When you first run Visual Studio 2010 (VS2010), it asks you to select a profile (e.g. C#, C++). This determines the Start Page displayed when VS2010 starts. Once you pick this, there appears to be no easy way to change your selection (at least none that I've found). To see which start pages are available to you, look in the following directory:
32-bit Windows: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\StartPages\en
64-bit Windows: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\StartPages\en
Note: you may also need to change your language directory from "en" to your local environment.
You will potentially see a number of files named "Links.<Version>.<VS2010-Language>.xml". The part we're interested in is the <VS2010-Language", e.g. CSharp, FSharp, VC.
To determine which page you current use, browse in Regedit.exe or use the following command:
reg query HKCU\Software\Microsoft\VisualStudio\10.0\StartPage\Default /v Links
You should see a result similar to the following:
Links REG_SZ CSharp
If you wish to change this to a different setting, pick another <VS2010-Language> from the list you saw in your StartPages directory, such as "VC". You can make this change in Regedit.exe or use the following command:
reg add HKCU\Software\Microsoft\VisualStudio\10.0\StartPage\Default /v Links /t REG_SZ /d VC /f
Now restart VS2010 and you will see your new Start Page.
Rob
Final Solution: I figured it out! Open your project in VS2010, select the Project menu and choose Properties..., and click the dropdown next to Platform Toolset. You can select between v100 (VS2010), v90 (VS2008), and Windows7.1SDK. Select the 7.1 SDK and click OK. Now you're all set. Note that you can use v90 to build apps that compile for older versions of Windows as long as you have VS2008 already installed on your machine.

---------
The information below is just kept to remind me what I did. It isn't terribly important.
---------
Update: I have found that the best way to utilize the V7.1 SDK is to launch VS2010 from a Windows V7.1 SDK Command Prompt. If I find a better way, I will post it here.
So, I realized today that I'm still building against the v7.0A SDK that ships with Visual Studio 2010 (VS2010). While not a crime, I wanted to make sure that I was building against the latest and greatest SDK. To change the version of the current SDK in VS2010, follow these directions:
-
In Visual Studio 2010, open a solution (.sln) file or create a solution.
-
In Solution Explorer, right-click the solution node and then click Properties.
-
In the Configuration list, select All Configurations.
-
Under Configuration Properties, select General.
-
As the Platform Toolset option, select Windows7.1SDK.
-
Click OK.
(Copied from MSDN : http://bit.ly/do5OLY)
However, I found that this didn't completely solve my problem. I had converted this VS2008 project to VS2010 before setting the SDK version and some of the project settings still pointed to the SDK V7.0A directories! How frustrating!
The following environment variable directories within VS2010 had been updated correctly or added:
- $(ExcludePath)
- $(ExecutablePath)
- $(IncludePath) -- mostly correct
- $(LibraryPath)
- $(PlatformToolset)
- $(PlatformToolsetVersion)
- $(WindowsSdkDir)
- $(WindowsSdkMSBuildTools)
- $(WindowsSdkNetFx35ToolsDir)
- $(WindowsSdkNetFx40ToolsDir)
- $(WindowsSDKVersionOverride)
But the following had not:
- $(FrameworkSDKRoot)
- $(SDK35ToolsPath)
- $(SDK40ToolsPath)
I did find hard-coded references to the V7.0A directory in my solution's .suo file, so I deleted it; this did not correct the problem.
I found the following entries in the registry that pointed to my V7.0A entries:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- FrameworkSDKRoot (REG_SZ)
- $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A@InstallationFolder)
- SDK35ToolsPath (REG_SZ)
- $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx35Tools-x86@InstallationFolder)
- SDK40ToolsPath (REG_SZ)
- $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86@InstallationFolder)
Thursday, September 09, 2010
For those of you who have pinned any program to your Windows 7 taskbar, you can hold down the Ctrl and Shift keys when clicking the icon and it will launch it with Administrator privileges.
I use this frequently when I need to run Visual Studio 2010 with Administrator privileges, but it will work with any program.
Now I just need someone to write a VS2010 Extension to relaunch VS2010 with Administrative privileges for the same Solution file. Maybe I have a new project on my hands...
Rob