September 15, 2012

WP7: Changing the Windows Live ID without loosing anything

Hey folks!

Background
I think I'm not the only one who created a cool email address Windows Live ID which is associated to an anime or comic character. As I got older I wanted to start using my real name which can be useful when applying for a job etc.

Well, I created a new Windows Live ID and started using it for everything - except my Xbox Live account was still connected to my old email address. And that's the point. When I bought my Windows Phone 7 I associated it with the Windows Live ID which was connected to my Xbox Live account - the old one.

In the end I wanted my Xbox Live account being associated to my new Windows Live ID which I want to use on my Windows Phone. After some investigation I found out how I was able to do that without lossing anything. I kept my applications and games I purchased as well as all Microsoft Points!

Now let's re-associate our Xbox Live account and finally change the Windows Live ID on our Windows Phone!


Solution
prereq
1) Xbox
2) Windows Phone 7 + Connection Cable for your PC/Notebook
3) Internet Connection
4) Patience

September 1, 2012

Abstract Language

Today a friend asked me how to create a German and a separated English abstract in LaTeX. Sure, you would say: Just write one abstract in German and the other one in English, where is the problem? Well that was not the problem. The problem was that LaTeX did always print "Zusammenfassung" (which is the German word for "Abstract") for both, the German and English version when using the abstract command:
\begin{abstract}
Long story short, it's very easy to use another language for all your commands - in case the requested language is installed.
\begin{abstract} Das ist meine Kurz- oder Zusammenfassung auf Deutsch... \end{abstract} \begin{otherlanguage}{english} \begin{abstract} This is my abstract written in English... \end{abstract} \end{otherlanguage}
Last make sure you defined you languages correctly in your main document as shown below
\usepackage[english,ngerman]{babel}
You see, only one additional command is necessary to accomplish this task.

August 30, 2012

C# Office Communication without COM Reference

Lately I needed to communicate with Microsoft Word from C#. Well most programmers would use a reference to the COM library which is provided by Microsoft. For some reasons I don't want to use these libraries. One reason is the version problem. Let's say I'm linking the COM library which was implemented for MS Word 2007 and use it's interfaces etc. I won't be able to run this program on a machine having MS Word 2003 or MS Word 2010 installed. To keep the whole story short, I'd like to show you a way how you can communicate with Microsoft Office without linking the COM libraries. The following sample shows how to search for a specific string in a Word document. Because I don't want to break the explanation of how the code works, I'll just post all DllImports, interface and class declarations here.
static readonly Guid IID_IDispatch=new Guid("{00020400-0000-0000-C000-000000000046}"); [Guid("00020962-0000-0000-C000-000000000046")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IWordWindow { } [DllImport("oleacc.dll")] public static extern int AccessibleObjectFromWindow(IntPtr hwnd, uint dwObjectID, byte[] riid, out IWordWindow ptr); [DllImport("user32.dll")] public static extern int BringWindowToTop(IntPtr hwnd); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow); [DllImport("user32.dll")] public static extern bool IsIconic(IntPtr hWnd); [DllImport("user32.dll")] public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); public delegate bool EnumChildCallback(IntPtr hwnd, ref IntPtr lParam); [DllImport("user32.dll")] public static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildCallback lpEnumFunc, ref IntPtr lParam);
The interface IWordWindow is the IDispatch COM interface for the Word COM object. If you want to use another Office Program, you'll have to adapt the Guid attribute (see MSDN). First of all we need the process of Word

August 1, 2012

C# File OpenAs Dialog (Win7)

Some time ago I ran into something weird. These lines of code worked perfectly the last years in order to show the open as dialog on Windows XP but stopped working on my x64 Windows 7 machine (it would have stopped working in Vista too, but I skipped this version).
ProcessStartInfo startInfo=new ProcessStartInfo() { WindowStyle=ProcessWindowStyle.Normal, FileName=fileName, Verb="openas", UseShellExecute=true, ErrorDialog=true, }; p=Process.Start(startInfo);
Well to solve this issue I needed to check how the system used to show the open as dialog. As a result, I ended up with this line of code which brings up the open as dialog as usual.
p=Process.Start("rundll32.exe", string.Format("shell32,OpenAs_RunDLL \"{0}\"", fileName));
By the way, you'll need both versions if you want that your application works on Windows XP and later versions. This line indicates whether the application is running on Windows Vista or later.
Environment.OSVersion.Platform==PlatformID.Win32NT && Environment.OSVersion.Version>=new Version(6, 0, 6000);