Windows Programming Archives | CodeGuru https://www.codeguru.com/windows/ Wed, 30 Nov 2022 20:59:01 +0000 en-US hourly 1 https://wordpress.org/?v=6.3.2 How To Make Windows 11 Faster https://www.codeguru.com/windows/optimize-windows-11/ Wed, 30 Nov 2022 20:59:01 +0000 https://www.codeguru.com/?p=19526 Windows 11 came with an updated interface, a customizable Start menu and taskbar, and a plethora of features. But what many users probably looked forward to the most were performance improvements, which came thanks to better disk usage, memory management, and other resource tweaks to help machines running Windows 11 enjoy speedier operations. Unfortunately, not […]

The post How To Make Windows 11 Faster appeared first on CodeGuru.

]]>
Windows 11 came with an updated interface, a customizable Start menu and taskbar, and a plethora of features. But what many users probably looked forward to the most were performance improvements, which came thanks to better disk usage, memory management, and other resource tweaks to help machines running Windows 11 enjoy speedier operations.

Unfortunately, not everyone is happy with how Windows 11 performs on their devices. If you are one of those dissatisfied or underwhelmed customers, here are some tips to make Windows 11 faster and optimize Windows 11 features.

Looking to get the most out of your Microsoft Office? We have some great Microsoft Office Productivity Tips to help make your more productive!

Why Is Windows 11 Slow?

Before we jump into tips and tricks to make Windows 11 faster, let us look at some reasons why its performance may not be up to snuff in the first place on your computer. If you find yourself asking: “Why does Windows 11 seem slow?”, the answer may include:

  • You may be using an old or fragmented device that Windows 11 may not support, which is making your computer seem almost unusable
  • Your computer specs are low and incapable of supporting snappy performance
  • You have not been keeping up with Windows or driver updates that are causing your computer to crash or act sluggish
  • Your RAM is running low and causing poor performance
  • You are lacking disk drive space
  • You have too many apps that are loading at startup
  • Viruses and malware are overwhelming your system
  • You have a slower hard disk drive (HDD) instead of a faster solid-state drive (SSD)
  • You are running Windows software that is corrupted or was installed incorrectly

Tips To Speed Up Windows 11

If you are not happy with the performance of Windows 11, here are some tips to speed it up. While some tips may seem super simple, you would be surprised at how many people overlook them and the wonders they can work with minimal effort:

Restart Your Computer

Restarting your computer is a quick way to clear the cobwebs and get Windows 11 running faster. It may not be the best long-term solution if you continue to have issues, but many find that simply restarting their computers results in a less sluggish Windows 11. This helps because, as time passes, resources continue to be used. This is especially true for programs like Internet browsers, which are notorious for memory leaks, where the longer an application runs, the more resources (aka RAM and processing power) it takes up. Rebooting your system helps to release the grip these “resource hogs” have on your memory.

Scan For Malware

Your computer’s specs may be up to snuff for handling Windows 11, but malware and viruses could be hiding underneath the surface and making performance suffer. If you have not done so already, run a virus scan using antivirus software to see what comes up. Be certain to update your antivirus definitions before you run a scan to make sure you are protected from the latest threats.

Give Your Computer Breathing Room

Is your CPU in a really tight spot with little room around it? If so, it may have trouble “breathing” and require more space around it so hot air can be released appropriately. Although many modern computers combat temperature spikes, you may find that getting your computer out of a cramped setting prevents heat buildup that can slow down performance and make Windows 11 seem a lot slower than it should be.

Read: Microsoft Office 365 Review

Get Rid Of Unnecessary Files

As mentioned, one possible reason for sluggish Windows 11 performance could be that your computer has little space left on its hard drive. To free up space and unlock speed, delete files you no longer need. Examples of unnecessary files that take up space and negatively impact performance are zipped files you have already extracted and setup files used to install apps. The same holds true for temporary files.

You can boost Windows 11 speed by eliminating temporary files. To do so, click the Start button and select the Settings option. Click on System, followed by Storage. Next, click on Temporary Files and choose what you want to get rid of. Complete the process by clicking on Remove files. By eliminating temporary files like your Internet history, cookies, and cache, you can free up space on your hard drive and hopefully see swifter Windows 11 performance.

Windows 11 Start Menu

Eliminate Unnecessary Apps

Chances are, your computer has some apps sitting on it that you never use or never wanted to be installed in the first place (aka bloatware). Get rid of these apps, and you can make more room on your hard drive and achieve better Windows 11 speed.

To remove unnecessary apps, click the Start button and select Settings. Next, click on Apps in the left pane, followed by Apps & features. Once you see the list of apps on your computer, click on the three vertical dots next to the ones you want to get rid of. Select Uninstall to remove them from your computer by following the prompts for each app.

Update Windows 11

Sluggish performance may not be the fault of your computer. Instead, it could be an issue triggered by a Windows 11 bug. Once Microsoft finds the fix, you can install the latest patch, so your version of Windows 11 is up-to-date, bug-free, and as fast as can be.

To check for a Windows 11 update, go to Settings on your computer. In the left pane, click on Windows Update. Next, click on Check for updates. Your computer will let you know if you are up to date. If not, it will find the new update(s) and install it/them. Restart your computer once the updates are installed, and you should hopefully see a speed improvement.

Reduce Your Startup Apps

If you have a ton of apps set to ignite once your computer starts, that can hamper your performance. An easy way to boost Windows 11 performance is to be more selective with your startup apps.

You can reduce your number of startup apps by clicking on the Start button. Next, select Settings and then Apps. From the Apps menu, click on Startup. From there, pick which apps you want to have on at Startup. For the best results, only have a minimal number of apps set to On so your computer does not get bogged down when starting.

Read: Best Microsoft Office Add-ins and Plugins

Reduce Your Startup Programs

With your startup apps minimized, it is now time to do the same with programs. Click the Start button, then select Task Manager. Next, click on the Startup tab. If you see programs you do not want to launch at startup, switch them from Enabled status to Disabled. By having fewer items set to launch at startup, you should see a faster boot time with Windows 11.

Select A High-Performance Power Plan

You can unlock more powerful performance on your PC for faster Windows 11 by doing the following. First, click Start. In the search bar, type “power plan” without the quotes. Next, click on Choose a power plan. On the Choose or customize a power plan page, select High performance. Then, click on Change plan settings. On the next page, click on Change advanced power settings. Under Processor Power Management, you want the minimum and maximum processor state set to 100%.

Turn Off Visual Effects

Visual effects can provide a more eye-catching experience when using your computer, but they can also negatively impact performance and make Windows 11 a drag to use, especially on older PCs. Disable visual effects, and you can decrease the burden on your GPU by about 20 percent for a faster Windows 11 experience.

To achieve this goal, press the Windows key. In the search bar, type “view advanced” without the quotes. Next, select View advanced system settings and click on the Advanced tab. In the Advanced tab under the Performance section, select Settings. On the Performance Options page, click on Adjust for best performance. Finally, under the Custom list, click these two options, so they have a checkmark next to them:</p.

  • Show thumbnails instead of icons
  • Smooth edges of screen fonts

Click on Apply, followed by OK, to save those changes and speed up Windows 11.

Read: Project Management Software for .NET Developers

The post How To Make Windows 11 Faster appeared first on CodeGuru.

]]>
Working with the Windows Registry in C# https://www.codeguru.com/csharp/windows-registry-c-sharp/ Fri, 17 Jun 2022 22:43:55 +0000 https://www.codeguru.com/?p=19310 The Windows Registry is a database that stores information pertaining to your computer in a hierarchical manner. In this programming tutorial, we will examine how to work with the Registry in C#. We will cover the basics of how the Registry works, and then we will show you how to use the Registry class in […]

The post Working with the Windows Registry in C# appeared first on CodeGuru.

]]>
The Windows Registry is a database that stores information pertaining to your computer in a hierarchical manner. In this programming tutorial, we will examine how to work with the Registry in C#. We will cover the basics of how the Registry works, and then we will show you how to use the Registry class in C# to programmatically add, update, or delete registry key/values.

Want to learn more C# programming and prefer a course tailored to C# developers? TechRepublic Academy has a great online programming class: The Complete C# Master Class Course we highly recommend.

What is the Windows Registry?

In the Windows operating system, the Registry represents a hierarchical database composed of keys, subkeys, predefined keys, hives, and value entries used to store data specific to a system or application. You may use the Windows Registry to save configuration details for your application so you can access them later if necessary.

Example of the Windows Registry

The Windows Registry was first introduced in Windows 95 and has been included in every subsequent version of Windows. It is a critical component of your operating system, and if it becomes corrupt, your system may become unstable or even unusable. For this reason, it is important to back up your Registry regularly.

Anatomy of the Windows Registry

As stated, the Windows Registry is a hierarchical database that holds information pertaining to the operating system such as the computer’s hardware, software, and user preferences. In other words, the Registry is used by the operating system and applications to store configuration data. The Registry key structure resembles a file system directory tree in which each node may contain a value or another subkey.

The Registry is divided into five main sections: HKEY_LOCAL_MACHINE, HKEY_CURRENT_CONFIG, HKEY_CLASSES_ROOT, HKEY_USERS, and HKEY_CURRENT_USER. Each section contains different types of data.

  • HKEY_CLASSES_ROOT: Stores information about registered applications, including file associations and OLE object class definitions.
  • HKEY_CURRENT_USER: Stores settings for the current user. This is where most application settings are stored.
  • HKEY_LOCAL_MACHINE: Stores settings that apply to all users on the machine, such as installed applications and device drivers.
  • HKEY_USERS: Stores settings for all users on the machine. This is primarily used by system administrators.
  • HKEY_CURRENT_CONFIG: This contains information related to the current hardware configuration. This is primarily used by system administrators.

Getting started with the Registry in C#

The C# programming language provides support for working with the Windows Registry through the Microsoft.Win32 namespace. The Registry class is the main entry point for interacting with the registry. It contains static methods for reading and writing to the registry, as well as a static property that gives access to a RegistryKey object representing the current user’s profile. The RegistryKey class in this namespace can be used to create, open, and close keys in the Registry.

You can add, edit, and delete keys and subkeys in C#. You can also read, add, and delete values from the registry. Analogous to a folder and subfolders inside a folder, a registry can have keys and subkeys.

Read: Project Management Software for .NET Developers

How to Retrieve a Value from the Registry in C#

To retrieve a value from the Registry, you can use the GetValue method of the Registry class. This method accepts two parameters: the key path and the value name. A key path represents the path to the key that holds the value you want to retrieve.

Here is an example of how to use GetValue to retrieve a value in C#:

string keyPath = @"HKEY_CURRENT_USER\MyTestKey"; 
string valueName = "MyTestValue"; 
object testValue = Registry.GetValue(keyPath, valueName, null);

Here, we are retrieving the value named “MyTestValue” from the key named MyTestKey.

How Do I Add Data to the Registry in C#?

To add a new Registry key and value, developers can use the following C# code:

Registry.SetValue("HKEY_CURRENT_USER\\TestApp", "TestKey", "TestValue");

To create a new subkey, use the CreateSubKey method of the Microsoft.Win32.Registry class. For example, to create a new key called “TestKey” under the “HKEY_CURRENT_USER” key, you would use the following C# code:

RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("TestKey");

The RegistryKey class represents a key in the registry. It can be used to create new keys, or open existing ones. Once a key is opened, its values can be read and written using the GetValue and SetValue methods. The following code snippet illustrates how you can leverage the CreateSubKey method to create a subkey and then add data into it with C#:

RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\TestSubKey");
registryKey.SetValue("Key_A", "Value A");
registryKey.SetValue("Key_B", "Value B");              

To delete a key, use the DeleteSubKey method. This will delete a key and all of its subkeys. For example, to delete the “TestKey” key, you would use the following code:

Registry.CurrentUser.DeleteSubKey("TestKey");

To delete a registry key and its subkey tree you can use the following code:

Registry.CurrentUser.DeleteSubKeyTree("TestApp");

Read: C# Tools for Code Quality

How Do I Retrieve Data from the Registry in C#?

Programmers can take advantage of the RegistryKey class to retrieve data from the Windows Registry. We can also use this class to create, open, or delete keys, to enumerate subkeys, and to access values in the key. To open an existing key, we use the OpenBaseKey method:

RegistryKey key = Registry.OpenBaseKey(RegistryHive.LocalMachine, "SOFTWARE\\KeyA\\KeyB");

How Do I Remove Data from the Registry in C#?

To remove data from the registry, you can leverage the RegistryKey.DeleteValue() method. To use this method, you will need to pass in the name of the value that you want to delete. For example, to delete a value named “TestValue”, you would use the following code:

using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("TestKey", true))
{
    if (registryKey == null)
    {
        // The key doesn't exist in the registry.
        // Hence, write your code to handle the error here.
    }
    else
    {
        registryKey.DeleteValue("TestValue");
    }
}

This will delete the specified value from the Registry.

How to Backup and Restore the Registry in C#

To back up the Windows Registry, you have two choices: using the Registry class or the WINREG API.

We will use the Registry class here. To back up the registry, you can use the ExportRegistryTree method. This method takes two parameters: the key to export and the file name to export to. The following code snippet illustrates how it can be used:

Registry.ExportRegistryTree(Registry.LocalMachine, "backup.reg");

This will export the entire registry to the backup.reg file. You can also specify a specific key to export, as shown in the code snippet given below:

Registry.ExportRegistryTree(Registry.CurrentUser, "backup.reg");

To restore the registry that was backed up previously, you can use the following code snippet:

Registry.ImportRegistryFile("backup.reg", true);

This will import the entire registry from the backup.reg file, overwriting any existing keys. You can also specify a specific key to import, like this:

Registry.ImportRegistryFile("backup.reg", Registry.CurrentUser, true);

This will import the entire registry from the backup.reg file, overwriting any existing keys.

Final Thoughts on Windows Registry Programming in C#

In this C# programming tutorial, we have looked at how to create, open, and close keys as well as how to read and write values. Just be sure to take care when working with Registry keys and values, as accidental deletion or modification can lead to serious problems on your computer running the Windows operating system.

Read more C# programming and software development tutorials.

The post Working with the Windows Registry in C# appeared first on CodeGuru.

]]>
Using Multiple Programming Languages to Create an ASP.NET Website https://www.codeguru.com/dotnet/asp-net-website/ Sat, 11 Jun 2022 23:21:57 +0000 https://www.codeguru.com/?p=19302 Did you know it is possible to use more than one programming language in a .NET website project? However, you cannot directly put source code files of different programming languages in the App_Code folder of your ASP.NET website project. by doing so, you would not be able to compile the source code files written in […]

The post Using Multiple Programming Languages to Create an ASP.NET Website appeared first on CodeGuru.

]]>
Did you know it is possible to use more than one programming language in a .NET website project? However, you cannot directly put source code files of different programming languages in the App_Code folder of your ASP.NET website project. by doing so, you would not be able to compile the source code files written in the different languages. In this .NET programming tutorial, we will show you how to create a .NET web app that can make use of more than one programming language.

Read: C# Tools for Code Quality

As an example, let’s say you have created a .NET website project in C# and also want to include another source code file that is written in Visual Basic (VB) into the same project. In this scenario, adding the two distinct source code files into the App_Code folder would not work. In order to make your ASP.Net website work based off more than one language, one solution would be, if the source-code file is small, a developer could convert the VB code into C# code on their own, or use any automated code converter to perform the same action.

However, if that source-code file is larger, or you want to use multiple programming languages for some reason (for example, if one language had features another did not natively have), then converting code from one programming language to another would be very time-consuming and an ineffective task.

Fortunately, there are other methods programmers can use to achieve this goal. We will start by creating a website from scratch, then move on to creating language-specific classes, make some changes in the website configuration, and, finally, test the functionality of our website.

How to Create an ASP.NET Website

To begin, let’s create the framework for our website using the Visual Studio integrated development environment (IDE). Follow the steps below:

  • Launch the Visual Studio IDE and create a new project by clicking on Create a new project.
  • Select ASP.NET Web Application (.NET Framework). Choose the programming language C# from the language dropdown option and click Next.

ASP.NET Web Development

  • On the next screen, configure your website project name and directory and then click Next.
  • Now you should see your website project template has been created by Visual Studio.

Since you are working out of Visual Studio, you may want to check out the features of the new .NET Coding Pack, to add even more features to your code editor.

Creating language-specific Classes in .Net

In this part of the process, we will create two class files in two different languages: C# and Visual Basic. Following are the steps required to create two distinct classes in the App_Code folder:

  • In the Solution Explorer, create two separate folders for each of the programming languages.
  • In this tutorial, we are going to create two subfolders called CS and VB, and add two source code files named ClassCS.cs and ClassVB.vb into them.
  • Add the following source code into the ClassCS.cs file by overwriting the existing source code:
public class ClassCS 
{ 
   public string Message; 
   public string GetMessage() 
   { 
      return this.Message; 
   } 
}

Next, add the following source-code into the ClassVB.vb file by overwriting the existing source-code:

Public Class ClassVB
 
    Public Message As String
 
    Public Function GetMessage() As String
        Return Me.Message
    End Function
 
End Class

Now you are ready to move onto the next step, which is modifying the configuration of our newly created ASP.Net website.

Modifying Website Configuration in ASP.Net

After creating the two separate files for two different programming languages in steps above, the next step is to change the website configuration so that ASP.NET can compile the two distinct folders separately. To change the configuration, follow the below steps:

  • Open the web.config file and locate the section in the file.
  • Add the section, as written below, inside the section.
   
      
      
   

Testing the Functionality of .NET Classes

After the website is configured successfully, let us now test if .NET can compile our two distinct source code files. To check if everything is working well, take the following steps:

  • Create a Default.aspx page in your project folder.
  • Create a label and two button controls on the Default.aspx page.
  • On the click-event of the first button, we want to call the function written in ClassCS. Similarly, on the click-event of the second button, we want to call the function written in ClassVB. The code should look as follows:
protected void Button1_Click(object sender, EventArgs event)
{
   ClassCS obj = new ClassCS();
   obj.Message = "C# Function is called!";
   Label2.Text = obj.GetMessage();
}
 
protected void Button2_Click(object sender, EventArgs event)
{
   ClassVB obj = new ClassVB();
   obj.Message = "VB Function is called!";
   Label2.Text = obj.GetMessage();
}

  • Next, in the Solution Explorer, right-click the Default.aspx page and select Set as Start Page and run the website project.
  • In the last step, we want to test our classes. Call the function of a specific class on the click of the corresponding button. For instance, if you click on the second button, you should see the message: ‘VB Function is called!’

ASP.NET coding examples

Final Thoughts on ASP.Net Muti-langage Web Pages

Using multiple programming languages in ASP.NET is useful in situations where developers and programmers are working independently and they may be using different languages, according to their preferences to support multiple development teams. We hope you have now learned how to support multiple programming languages while building ASP.NET web projects.

Read more ASP.NET software development and programming tutorials.

The post Using Multiple Programming Languages to Create an ASP.NET Website appeared first on CodeGuru.

]]>
Finding a Microsoft Office version with .NET https://www.codeguru.com/csharp/office-version-dot-net/ Fri, 20 May 2022 23:36:55 +0000 https://www.codeguru.com/?p=19247 There are many ways for a developer to find the Microsoft Office version in .NET, but today we will show you one of the more complicated ways – just as an opportunity to fine-tune your C# coding skills. We will be working with the computer’s Registry system. If you are not familiar with the Registry, […]

The post Finding a Microsoft Office version with .NET appeared first on CodeGuru.

]]>

There are many ways for a developer to find the Microsoft Office version in .NET, but today we will show you one of the more complicated ways – just as an opportunity to fine-tune your C# coding skills. We will be working with the computer’s Registry system. If you are not familiar with the Registry, what its function is, or how to navigate it, please refer to the Microsoft documentation regarding Registry here. We will also do a bit of 64 bit and 32 bit checking in between. We will not go into too much detail on the bit-ness, because the chances are slim that we want to determine an Office version which is lower than 2013.

Read: Access Office 365 REST APIs Using .NET Libraries

How to Find the Office Version in C#

With all of the above being said, let’s get started:

  • Open Visual Studio and create a new C# Windows application. Name it FindOffice_Ex
  • Add a button to the form. This button we will use to get the version of Office on the user’s machine.
  • Add a new class named Office to the solution.
  • Edit it to look like the following:
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace FindOffice_Ex
{
    public class Office
    {

        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]

        static extern uint RegOpenKeyEx(UIntPtr hKey, string lpSubKey, uint ulOptions, int samDesired, out int phkResult);
        [DllImport("Advapi32.dll")]
        static extern uint RegCloseKey(int hKey);
        [DllImport("advapi32.dll", EntryPoint = "RegQueryValueEx")]
        static extern int RegQueryValueEx(int hKey, string lpValueName, int lpReserved, ref uint lpType,
            System.Text.StringBuilder lpData, ref uint lpcbData);
        private static UIntPtr HKEY_LOCAL_MACHINE = new UIntPtr(0x80000002u);
        private static UIntPtr HKEY_CURRENT_USER = new UIntPtr(0x80000001u);

        private Dictionary<string, string> LatestVersions = new Dictionary<string, string>();

        public Office()
        {
            LatestVersions.Add("12.0", "Office2007");
            LatestVersions.Add("14.0", "Office2010");
            LatestVersions.Add("15.0", "Office2013");
            LatestVersions.Add("16.0", "Office2017 and higher ");
        }

        private string GetVersionNumberFromRegistry()
        {
            string regVersion;
         
                regVersion = GetVersionNumberFromRegistry("SOFTWARE\\Microsoft\\Office\\");
                if (regVersion == null)
                    regVersion = GetVersionNumberFromRegistry("SOFTWARE\\Wow6432Node\\Microsoft\\Office\\");
          
            return regVersion;
        }
        private string GetVersionNumberFromRegistry(string key)
        {
            string version = null;
            foreach (string VerNo in LatestVersions.Keys)
            {
                string offPath = Reg64(HKEY_LOCAL_MACHINE, key + VerNo + "\\Excel\\InstallRoot", "Path");
                if (offPath != null)
                {
                    version = VerNo;
                    break;
                }
            }
            return version;
        }
        public string GetVersion()
        {
            string versionFromReg = GetVersionNumberFromRegistry();
            string versionInstalled = LatestVersions[versionFromReg];

            bool? Office64BitFromReg = Off64Bit("SOFTWARE\\Microsoft\\Office\\", versionFromReg);
                
            if (Office64BitFromReg == null)
                    Office64BitFromReg = Off64Bit("SOFTWARE\\Wow6432Node\\Microsoft\\Office\\", versionFromReg);
                if (Office64BitFromReg.HasValue && Office64BitFromReg.Value)
                    versionInstalled += " (64 bit)";
                else if (Office64BitFromReg.HasValue && !Office64BitFromReg.Value)
                    versionInstalled += " (32 bit)";
                else
                {
                    versionInstalled += " (Unknown bit)";
                }
 
            return versionInstalled;
        }

        private bool? Off64Bit(string key, string version)
        {
            bool? Office64BitFromReg = null;
            string Bitness = Reg64(HKEY_LOCAL_MACHINE, key + version + "\\Outlook", "Bitness");
            if (Bitness == "x86")
                Office64BitFromReg = false;
            else if ((Bitness == "x64"))
                Office64BitFromReg = true;
            return Office64BitFromReg;
        }

        private string Reg64(UIntPtr parent, string key, string prop)
        {
            int ikey = 0;
            int bit36_64 = 0x0100;
            int query = 0x0001;
            try
            {
                uint res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, query | bit36_64, out ikey);
                if (0 != res) return null;
                uint type = 0;
                uint data = 1024;
                StringBuilder buffer = new StringBuilder(1024);
                RegQueryValueEx(ikey, prop, 0, ref type, buffer, ref data);
                string ver = buffer.ToString();
                return ver;
            }
            finally
            {
                if (0 != ikey) RegCloseKey(ikey);
            }
        }
    }
}

C# Code to Find the Office Version Explained

OK, so what does the C# code in our previous example do, exactly?

First, we added the required namespaces needed for this project, especially System.Runtime.InteropServices, since we will be making use of System APIs. With System APIs we can get access to the Operating System’s inner code.

Then, we declare the APIs so that we can work with them directly in our application. For more information about the System APIs, refer to the official Microsoft documentation here.

In the class’ constructor, we populate the LatestVersions dictionary with some versions of Office. Note that these versions range from Office 2007 to Office 365. Obviously, there are earlier versions, but we did not see the need to cater to them.

The following methods retrieve the Office version from the system’s Registry and determines if the version is 64-bit. Yes, a programmer could also test for a 64-bit operating system, but they are quite common these days, so we did not add that functionality.

Go back to your form and edit the button’s click event to the following, which allows us to get the value displayed inside a message box:

        private void button1_Click(object sender, EventArgs e)
        {
            string RunningOfficeVersion = new Office().GetVersion();
            MessageBox.Show("Running Office Number: " + RunningOfficeVersion);
        }

Now, when you run this program, a pop-up will appear showing you which version of Microsoft Office you are currently running.

Read more C# programming tutorials and software development guides.

Looking to upgrade to Microsoft Office 365?

 

Disclaimer: We may be compensated by vendors who appear on this page through methods such as affiliate links or sponsored partnerships. This may influence how and where their products appear on our site, but vendors cannot pay to influence the content of our reviews. For more info, visit our Terms of Use page.

The post Finding a Microsoft Office version with .NET appeared first on CodeGuru.

]]>
Cloud Computing Types Overview https://www.codeguru.com/azure/cloud-computing-types/ Thu, 07 Oct 2021 17:25:09 +0000 https://www.codeguru.com/?p=18592 Cloud computing is a hot topic among developers, filling the conversation in every field of information technology and business. There is a lot of misunderstanding when it comes to the types of cloud computing and the cloud in general between non-specialists and even among some veteran technology specialists. In today’s cloud computing tutorial, we seek […]

The post Cloud Computing Types Overview appeared first on CodeGuru.

]]>
Cloud Computing Tutorials

Cloud computing is a hot topic among developers, filling the conversation in every field of information technology and business. There is a lot of misunderstanding when it comes to the types of cloud computing and the cloud in general between non-specialists and even among some veteran technology specialists. In today’s cloud computing tutorial, we seek to clear up some of the confusion by defining the different types of cloud computing services.

Despite the fact that cloud computing has become an established technology over the past few years, it is still not easily available or free to the public in the same way that web hosting is. This may explain some of the reason why it is still misunderstood and most often confined to the role of cloud backup storage.

Up to this point in time, there are many businesses and companies that have not moved to the cloud, especially in developing countries and sensitive sectors such as financial, medical, government, and the military branches.

Despite the expectations, there are, in reality, some situations where the user still prefers on-premise solutions such as personal desktop computers versus cloud computer desktop services. There are also some states that put restrictions on companies, preventing them from moving to cloud servers outside the state for sovereign reasons.

With all of that in mind, let’s begin our journey to better understand what cloud computing is and how it applies to developers, programmers, and those in the information technology (IT) realm. We will also look at some of the more popular cloud services for developers.

What is Cloud Computing?

To begin, it is worth quickly offering a definition for cloud computing, if nothing else to make sure we eliminate some widespread stereotypes associated with the term. The most common thought about cloud computing is that it is just some kind of backup storage application. While that is technically correct – backup storage is one use of cloud computing – it is just one in a million of the different and wide variety of modern ways cloud computing is used.

Cloud tech technology is a versatile concept for a variety of terms like cloud computing, cloud infrastructure, cloud database, cloud storage, cloud-based, cloud server, and so forth. Simply put, it begins by using online remote resources (hardware and software functions) as a service in the sky (metaphorically). Although it is supposed to use the same computing physical hardware and software as regular servers, it has a different modern architecture to better suit servers’ availability and distribution over the Internet around the world.

Advantages of Cloud Computing

From securing cloud backup storage to enjoying sync apps across different devices, cloud computing is not confined only to such individual usage. At the business level, the advantages and use cases are more clear and numerous, especially in terms of reducing cost and minimizing capital expenditure.

Some examples of the benefits of cloud computing include:

  • Cut part of the operational costs for hardware, databases, servers, and software.
  • Get 24/7 uptime support and turn-to-zero probability of downtime.
  • Ability to scale resources up and down as needed all at once.
  • Stop worrying about any maintainability and updates; these are handled by the provider.
  • Getting data centers in any location as the business needs to increase speed and reliability.

Cloud Computing Types and Models

Cloud types are typically categorized into two kinds of classification: Cloud Delivery Model and Cloud Deployment Model. In the Deployment Model, the resources are the same but the difference is in location and ownership. While in the Delivery Model there are different levels for distribution of responsibility between the provider and the user.

Deployment Model

There are four main types of cloud computing based on the Deployment Model:

  • Private clouds: Cloud environments solely dedicated to a single end-user or company. It is used for private and sensitive sectors.
  • Public clouds: Pooled cloud environments shared for many users or companies. It keeps a good amount of privacy and independence and is less expensive.
  • Hybrid clouds: Contains both private cloud and public clouds models connected through local area networks. It is for users who have some usual and special needs.
  • Multiclouds: It is made from more than one cloud service and provider. Multiclouds are not hybrid clouds because they are separated. It is used for sensitive data and information.

Delivery Model

There are also four main types of cloud computing services based on the Delivery Model:

Infrastructure as Service (IaaS): Provides cloud computing at the level of fundamental infrastructure either as a real bare metal server or dedicated virtual server, in addition to the network and data storage. The user can install any operating system and application of their choice. The infrastructure update and maintenance are the provider’s responsibility, but the user is responsible for updating his OS and applications.

Platforms as a Service (PaaS): Here, the provider is responsible for infrastructure, operating system, and software framework. The user can install or develop their own applications. It is an ideal choice for developing web applications, where many developers can work together.

Software as a Service (SaaS): In this solution, the provider is responsible for nearly everything down to the software. The user has only the end service via paid subscription. It’s a great choice for CRM and mobile applications sales software. No need for worrying about anything which makes it also suitable for short-term projects.

Function as a Service (FaaS) or serverless computing: For providing solutions that run code separately. It’s a great choice to make essential application tasks that run with no need for coding them in the user applications, which makes it easier to maintain and develop them with lower cost and cloud usage.

In all of these options flexibility, reliability, and scalability are considered main features. That also helps to reduce the burden of office hardware and even the software in the (SaaS) option. Also, with pay-for-use features, it has become an ideal cost-effective IT solution for business growth – especially for startups.

Many sectors can get great benefits from cloud computing. The sectors that can benefit the most from the cloud IT revolution include:

  • Banking & Finance
  • Government
  • Search engines
  • Manufacturing
  • Robots and IoT
  • Artificial intelligence
  • Healthcare
  • Education
  • Software development
  • Web hosting
  • Pharmaceutical
  • Transport
  • Tourism
  • Real estate
  • IT/ITES

Cloud Service Providers for Developers

There are a lot of cloud service providers, but the top ten of are:

The post Cloud Computing Types Overview appeared first on CodeGuru.

]]>
Creating Hello World in Microsoft Windows 11 using C# https://www.codeguru.com/csharp/hello-world-c-sharp-windows-11/ Fri, 20 Aug 2021 06:47:52 +0000 https://www.codeguru.com/?p=18444 If you are a Microsoft Insider, then there is a chance you’ve already installed a pre-release of Microsoft Windows 11 onto your system. While Windows 10 was promoted as the last version of Windows when it was released, time has shown that a new version was desired to help reset hardware expectations and promote a […]

The post Creating Hello World in Microsoft Windows 11 using C# appeared first on CodeGuru.

]]>
If you are a Microsoft Insider, then there is a chance you’ve already installed a pre-release of Microsoft Windows 11 onto your system. While Windows 10 was promoted as the last version of Windows when it was released, time has shown that a new version was desired to help reset hardware expectations and promote a few new features. Sometimes the evolution of an operating system simply needs a new number – in this case, the new number is 11.

With terms like “flexible” and “fluid” used by Microsoft to describe the update, it is possible to have flashbacks to Windows Vista. Of course, market terms like “reliable”, “secure”, “connected”, and “performant” are also used by Microsoft to describe Windows 11.

System Requirements for Windows 11

Overall, Windows 11 is just another update to Windows 10. In fact, Microsoft has indicated that Windows 11 should be delivered later this year as an update to devices running Windows 10 that are eligible as well as on new devices that are capable of running the new features.

What makes a device eligible? Meeting the requirements for running the operating system, which include some standard expectations such as a processor running at a speed of at least one gigahertz (GHz). Faster is always better. The processor needs to have two or more cores on a 64-bit processor or a system on a chip (SoC). Additionally, 4 gigabytes (GB) of RAM are required. These have been relatively standard low-end criteria for systems for a while. Also required are:

  • 65 GB or more of storage
  • A graphics card that is compatible with Direct X or later with a WDDM 2.0 driver
  • Support for UEFI and Secure System Boot Firmware
  • Support for TPM 2.0 (Trusted Platform Module)
  • A high definition display including a 9” or greater monitor with 8 bits per color channel

Additionally, an internet connection is required for device setup. Also, depending on the features of Windows 11 that you want to use, you might need to meet other requirements. For example, if you want to use Voice Assist, then you would need a microphone and speakers. Similarly, if you wanted to use Snap with a three-column layout, then you’d need a monitor with a width of at least 1920 effective pixels. You can find a full list of Windows 11 hardware requirements at https://docs.microsoft.com/en-us/windows/whats-new/windows-11-requirements.

Earlier I mentioned Windows Vista. For those of you familiar with Vista, you know it suffered issues upon release. While Microsoft took a dink for the issues, those that looked closer knew that the problem was that manufacturers didn’t get their drivers updated as needed. It wasn’t Vista but the drivers that drove a big part of the problem. With Windows 11, most drivers and accessories that work for Windows 10 are expected to work. Of course, as with any operating system upgrade, you should confirm with device manufacturers that they’ve confirmed compatibility.

Hello World in Windows 11 and C#

Of course, this article is supposed to be about the legendary “Hello World” application developers create when reviewing something new. In this case, Windows 11 is new, so we need to create and run a “Hello Windows 11” app. To target Windows 11, you should use Visual Studio 2019 version 16.10 or higher.

What you can see when you run a Windows 11 app is that there has been a change in the styles used to present windows and dialogs. Windows 11 uses the Fluent Design System. This is an adaptive design that includes updates so that windows have slightly rounded edges, updated icons, and a bit more transparency.

Read: C# Programming for Beginners.

For this article, we will create a simple Universal Windows App (UWP) using the Visual Studio 2019 integrated development environment (IDE). Start by creating a new project and selecting the Blank App (Universal Window) using C# from the option:

C# Hello World Example

Click Next to launch the dialog asking for an app name and location. You can fill these in with “Hello 11” and a location that works for you. Click Create to proceed. You will be prompted to state the targeted version of Windows for your application. Because the primary way to have Windows 11 at the time of this article is to be in the Windows Insiders program, you’ll want to select Windows Insider Preview (Build 22000) or something similar.

Configure Windows 11 Project

Note that if you are not running Windows 11, then you will not be able to target Windows 11.

Click OK to create the application. Microsoft will create the basic project files as shown in the following figure.

Windows 11 C# Tutorial

Because we are going to use controls in our Hello World app, we need to add the WinUI library. At the time of this article, WinUI 3.0 did not support the new visual styles of Windows 11, so you need to use the WinUI 2.6.1 library. This can be added to your project by adding the Microsoft.UI.Xaml package and selecting version 2.6.1. You can add this by selecting Project then Manage NuGet Packages… from the menus, then clicking Browse (or right-click in the Solution Explorer and select the same). You’ll then be able to search and click on Microsoft.UI.Xaml to add it to your project.

With the package added to the solution, let’s add a reference from our code. Open the App.xml file and add the reference so we can use the resources. Your App.xaml listing should look like the following:

<Application

    x:Class="TEST1.App"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:TEST1">

    <Application.Resources>

        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />

    </Application.Resources>

</Application>

We are now ready to update the code to say “Hello” to the world and also to display a few controls. For our simple demo UWP, you will need to add the namespace for the updated controls to the MainPage.xaml file. We’ll update what is in the default MainPage.xaml Grid control to display our “Hello” message and a few Windows controls as well as an updated RadioButtons control. Update what is in your Grid control to match the following code:

You can then compile and run the program on Windows 11 to see the dialog:

<Page

    x:Class="Hello_11.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:Hello_11"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:controls="using:Microsoft.UI.Xaml.Controls"

    mc:Ignorable="d"

    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>

        <ScrollViewer Height="800" Padding="20">

            <StackPanel Orientation="Vertical" HorizontalAlignment="Left" >

                <Line X1="0" Y1="0" X2="190" Y2="0" Stroke="Black" StrokeThickness="1" />

                <TextBlock Margin="11,1,1,1">Hello Windows 11 World!!!</TextBlock>

                <Line X1="0" Y1="0" X2="190" Y2="0" Stroke="Black" StrokeThickness="1" />
            
                <CheckBox Content="Unchecked CheckBox"/>

                <CheckBox Content="Checked CheckBox" IsChecked="True"/>

                <Slider Width="200"/>

                <controls:RadioButtons>

                    <x:String>Home</x:String>

                    <x:String>Business</x:String>

                    <x:String>Mobile</x:String>

                    <x:String>Other</x:String>

                </controls:RadioButtons>

                <Button Content="A Button" Margin=”10” />

                <controls:ColorPicker />

            </StackPanel>

        </ScrollViewer>

    </Grid>

</Page

Windows 11 C# Example

Of course, the thing about this application is that the code works on Windows 10 as well as Windows 11. Where the difference should be seen is when you run the code on Windows 11, dialog corners will be rounded, the appearance of the controls should be just a bit crisper/cleaner, and some of the control animations will be updated. In short, you don’t have to say “goodbye” to what you know about Windows 10 in order to say Hello to Windows 11!

Learn more about the Windows Insider Program.

The post Creating Hello World in Microsoft Windows 11 using C# appeared first on CodeGuru.

]]>
Draw a Stickman Epic https://www.codeguru.com/windows/draw-a-stickman-epic/ Mon, 06 May 2013 14:45:00 +0000 https://www.codeguru.com/uncategorized/draw-a-stickman-epic/ [description] Draw a stickman, and then guide him through a fantastic world of adventure. Using an assortment of pencils, draw elements, tools, and weapons to solve puzzles and overcome obstacles. Explore diverse environments and encounter unusual creatures as you draw your way through 14 levels (plus a hidden bonus level)! With the non-linear gameplay, how […]

The post Draw a Stickman Epic appeared first on CodeGuru.

]]>
[description]

Draw a stickman, and then guide him through a fantastic world of adventure. Using an assortment of pencils, draw elements, tools, and weapons to solve puzzles and overcome obstacles.

Explore diverse environments and encounter unusual creatures as you draw your way through 14 levels (plus a hidden bonus level)! With the non-linear gameplay, how you overcome one environment will determine which level you unlock next. Each level is filled with hidden secrets and achievements.

[/description]
[developmentnotes]

Draw A Stickman was developed using C# and Visual Studio. The original game targeted the Web, and was written with Javascript and SVG graphics.

Because of immediate initial demand, they decided to re-write it to be native on different devices. They knew SVG and JavaScript weren’t going to give them the frame rates they needed for an application. By using tools such as Xamarin, they were able to compile natively and get the performance they needed.

Hitcents was looking at whether to using Flash to iOS or Xamarin and settled on Xamarin (a good decision in retrospect). Xamarin’s Monogame framework would let them use the XNA APIs on all platforms. Additionally, they were a Microsoft shop using Mono, so, so they were already familiar with what Mono could do as well as with  Xamarin platforms. 

Microsoft asked Hitcents to port the application to Windows 8. In a first try to build the application for Windows, it only took about 4 hours because of the Xamarin platform they were using. Recently they added localization to provide twelve different languages. They were able to change this once on the back-end and have it built for the seven different platforms they target.

For more on the evolution of Stickman’s development, see Microsoft DevRadio: Using Xamarin to Create the Draw a Stickman app for Windows 8

[/developmentnotes]
[companyname]Hitcents[/companyname]
[price]2.99[/price]
[freetrial]freetrial_available[/freetrial]
[opensourceurl][/opensourceurl]

The post Draw a Stickman Epic appeared first on CodeGuru.

]]>
Tile Slider https://www.codeguru.com/windows/tile-slider/ Thu, 25 Apr 2013 21:05:00 +0000 https://www.codeguru.com/uncategorized/tile-slider/ [description] The Tile Slider Puzzle is about moving tiles up and down as well as right or left in order to set each row to the same color. You need to do this in the fewest moves possible. Each time you play, the board is randomized to allow for different challenges. Multiple game board sizes […]

The post Tile Slider appeared first on CodeGuru.

]]>
[description]

The Tile Slider Puzzle is about moving tiles up and down as well as right or left in order to set each row to the same color. You need to do this in the fewest moves possible. Each time you play, the board is randomized to allow for different challenges. Multiple game board sizes increase the difficulty.

The game includes randomized boards for multiple games as well as four different play board sizes. It is great for all ages.

[/description]
[developmentnotes]

The Tile Slider was a proof of concept application. It was built to learn about Windows 8 development. While the overall learning was relatively painless, there were a few pain points.

The one key lesson learned, however, was that Windows 8 development is not hard if you already know how to build Windows applications. The tools (Visual Studio 2012 Express or any of the other editions of Visual Studio) make it pretty easy to build the interface without knowing a lot of XAML or other mark-up. Additionally, the core logic is standard programming for a Microsoft developer.

I learned a couple of lessons building this application. These are pretty basic lessons for anyone building a Windows 8 Application:

  • Think about Snap and Fill from the start
  • Use Basic not Blank templates

Think about Snap and Fill from the start

To give the best experience in your application, you need to think about the device it is being used on. There are currently four different display modes that can be used with an application. The obvious are landscape and portrait modes. You should consider how your application is being used and disable one of these if it isn’t being used. Of course, it is always best to support both.

There are also snap and fill modes. These modes happen when a person snaps an app to the right or left side of the screen. Your application will be truncated if you don’t take these modes into consideration. I write about this in my blog post, 8 Days Until Windows 8: Don’t Forget Snapping and Filling.The image below illustrates snap and fill modes.

It is worth noting that there are rumors of future modes that might also be supported. As such, the more responsive you design your application to varying screen sizes, the better your application will adapt in the future.

Use Basic not Blank templates

In my blog post, I also write about using basic templates instead of the blank template. By default, a page in a Windows 8 app uses the blank template. The biggest benefit of using the basic template is that it actually includes a lot of the behind-the-scenes code for supporting the modes mentioned above. In fact, Visual Studio 2012 will allow you to use the designer to adjust and build the different mode interfaces easily if you use the Basic templates. I covered exactly how to do that in the day 8 article mentioned above.

[/developmentnotes]
[companyname]Quinstreet[/companyname]
[price]free[/price]
[freetrial][/freetrial]
[opensourceurl][/opensourceurl]

The post Tile Slider appeared first on CodeGuru.

]]>
Tile Slider Puzzle Game https://www.codeguru.com/windows/tile-slider-puzzle-game/ Thu, 25 Apr 2013 17:31:00 +0000 https://www.codeguru.com/uncategorized/tile-slider-puzzle-game/ [description] The Tile Slider Puzzle is about moving tiles up and down as well as right or left in order to set each row to the same color. You need to do this in the fewest moves possible. Each time you play, the board is randomized to allow for different challenges. Multiple game board sizes […]

The post Tile Slider Puzzle Game appeared first on CodeGuru.

]]>
[description]

The Tile Slider Puzzle is about moving tiles up and down as well as right or left in order to set each row to the same color. You need to do this in the fewest moves possible. Each time you play, the board is randomized to allow for different challenges. Multiple game board sizes increase the difficulty.

The game includes randomized boards for multiple games as well as four different play board sizes. It is great for all ages.

[/description]
[developmentnotes]

The Tlle Slider was a proof of concept application. It was built to learn about Windows 8 development. Overall the learning was relatively painless, but there were a few pain points.

[/developmentnotes]
[companyname]Quinstreet[/companyname]
[price]free[/price]
[freetrial][/freetrial]
[opensourceurl][/opensourceurl]

The post Tile Slider Puzzle Game appeared first on CodeGuru.

]]>
Developer.com Network Reader https://www.codeguru.com/windows/developer-com-network-reader/ Wed, 24 Apr 2013 21:39:00 +0000 https://www.codeguru.com/uncategorized/developer-com-network-reader/ [description]Official Developer.com Network Reader application used to read articles from Developer.com, CodeGuru.com, DevX.com, HTMLGoodies.com and PHPBuilder.com. Easily scroll through content from all of the sites at once and quickly jump to an article to read the full text. Using the Windows 8 Options charm you can customize the browser to use and/or which sites to […]

The post Developer.com Network Reader appeared first on CodeGuru.

]]>
[description]Official Developer.com Network Reader application used to read articles from Developer.com, CodeGuru.com, DevX.com, HTMLGoodies.com and PHPBuilder.com. Easily scroll through content from all of the sites at once and quickly jump to an article to read the full text. Using the Windows 8 Options charm you can customize the browser to use and/or which sites to read.[/description]
[developmentnotes]

The Developer.com Network Reader is a Windows 8 application that was built over the course of a few days. The application taps into RSS feeds to aggregate various content from the Developer.com network. The application code is available along with an article that shows how the code works. You can find this in the article, Building the Developer.Com Windows 8 App.

This application was relatively easy to build. It includes the ability to snap the application, to set custom options, and to do sharing. If you look at the article, you’ll see that the article lets you synchronize the RSS feeds and bind the data within the application.

Overall, the amount of coding necessary to create this application was minimal. The Visual Studio tool s and the framework take care of a lot of the heavy lifting. Check out the article here on Codeguru for more on the details of the code.

[/developmentnotes]
[companyname]QuinStreet[/companyname]
[price]free[/price]
[freetrial][/freetrial]
[opensourceurl]http://www.codeguru.com/csharp/.net/building-the-developer.com-windows-8-app.htm[/opensourceurl]

The post Developer.com Network Reader appeared first on CodeGuru.

]]>