Determine if Skype is Installed

Posted by Brian R Cline | .NET Framework,C#.NET,Programming | Tuesday 25 May 2010 4:54 pm

The easiest method of checking whether Skype is installed is actually to check for a Registry Key. We, of course, can’t check C:\Program Files for a Skype Directory because the user could have installed elsewhere (or maybe if 64 bit the operating system did?)

Skype’s API Document provides us with the following information:

To check if Skype is installed, in regedit check if the following key exists: HKCU\Software\Skype\Phone, SkypePath . This key points to the location of the skype.exe file. If this key does not exist, check if the HKLM\Software\Skype\Phone, SkypePath key exists. If the HKCU key does not exist but the HKLM key is present, Skype has been installed from an administrator account but not been used from the current account.

Generally, I only care if the Current User has configured Skype, so I will ignore the HKEY_LOCAL_Machine information and instead rely entirely on the HKEY_CURRENT_USER information.

You must make sure you reference: Microsoft.Win32 for the registry functions or modify the snippet slightly.

        using Microsoft.Win32;

        //Function uses Microsoft.Win32 to check registry value of
        //HKEY_CURRENT_USER\Software\Skype\Phone\SkypePath and returns false if
        //the key is null
        private bool isSkypeUser()
        {
            RegistryKey skype = Registry.CurrentUser.OpenSubKey(@"Software\Skype\Phone");

            if (skype != null && skype.GetValue("SkypePath") != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

Books I’ve Read

Posted by Brian R Cline | .NET Framework,C#.NET,Excel,Experience,Programming,asp.net | Tuesday 8 September 2009 9:24 am

Sometimes, when I have applied for full time employment in the past I have seen job ads or received responses from companies asking what books I’ve read. Nearly every time, I have heard this question I was so shocked because I didn’t ever keep track of what I had read or where I had gleamed those little bits of valuable information.

This list will be updated at least monthly, although when I have an abundance of extra time I might be able to read an additonal book or two. Please note that this list only contains books I am interested in professionally and in no specific order.

Books Finished:

  • ASP.NET 2.0 Unleashed
  • Beginning Ubuntu Linux
  • C# How to Program
  • Code Craft: The Practice of Writing Excellent Code
  • Don’t Make Me Think: A Common Sense Approach to Web Usability
  • jQuery In Action
  • Network+ Guide to Networks
  • Learn to Program With C++
  • Practical Web 2.0 Applications with PHP
  • Systems Analysis and Design in a Changing World
  • Teach Yourself HTML 4 in 24 Hours
  • Visual Basic 6 Complete
  • Web Style Guide: Basic Design Principles for Creating Web Sites

Currently Reading:

  • Operating System Concepts

Although the list is getting pretty extensive, please understand that these are books I can verify as of September 7th 2009. The title suggests this is only books, so please remember that I definitely have visited many websites along the way.

Sending Emails from C#.NET

Posted by Brian R Cline | .NET Framework,C#.NET,Programming | Wednesday 5 August 2009 5:03 pm

Often, I work on software that needs to have the most minimal downtime possible. For example, I wrote a large chunk of server code that needs to handle CRM data for a small but completely distributed sales team. One of the methods, I use to try and reduce the downtime is to have the software email me whenever an exception is thrown or when some sort of event occurs.

Emails are incredibly easy to send from .NET especially your typical plaintext email. We will be making use of the System.Net.Mail namespace along with an smtp server you should already have setup or you could use a free one like Gmail.

A number of Canadian Internet Service Providers (ISPs) require you use their local SMTP Server (by blocking port 25), you should contact them if you think this will be an issue. Please note that some ISPs like Bell Sympatico do this to avoid being blacklisted for spam.

using System;
using System.Windows.Forms;
using System.Net.Mail;

namespace BRCline1
{
public partial class frmEmailer : Form
{
private const string SMTPServer = “Your_SMTP_Address_Or_IP_Goes_Here”;
private const string FromAddress = “The_Sender_Address_Goes_here”;
private const string FromAddressPassword = “The_Sender_Password_Goes_here”;
private const int SMTPPort = 25; //Could also be another port

public Form1()
{
InitializeComponent();
}

private void btnSend_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SMTPServer);

mail.From = new MailAddress(FromAddress);
mail.To.Add(“address@fakedomain.com”);
mail.Subject = “Your_Subject_Goes_Here”;

//Change this boolean to true, and you could send a simple html email
mail.IsBodyHtml = false;

mail.Body = “This is my first auto email”;

SmtpServer.Port = SMTPPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(FromAddress, FromAddressPassword);

SmtpServer.Send(mail);
}
}
}

Please note that you should always have some sort of exception handling for any operation that depends on a network connection or another system from responding.

How To Stop A .NET Form from Closing

Posted by Brian R Cline | .NET Framework,C#.NET,Programming,VB.NET | Friday 10 July 2009 1:22 pm

I always find it so amazing how people don’t or won’t bother to spend even five minutes using a search engine like Google to find out about how to do something and instead spend more time posting a question on Yahoo! Answers.

We simply add e.Cancel = true to the Form’s Closing Event, there are two simple examples below.

Closing a Form in C#.NET goes like this:

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true
}

Closing a Form in VB.NET goes like this:

Private Sub Form1_Closing(ByVal sender As Object, ByVal e AsSystem.ComponentModel.CancelEventArgs)
e.Cancel = True
End Sub