using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using Microsoft.Win32;

public partial class UserDefinedFunctions
{
  [Microsoft.SqlServer.Server.SqlFunction]
  public static SqlString ReadRegSingle(SqlString key, SqlString value)
  {
    //HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.1\\Setup
    //SQLPath
    return new SqlString((string)Registry.GetValue(key.Value, value.Value, null));
  }
};

