C# code for the Windows version