-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathProgram.cs
67 lines (59 loc) · 2.53 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SMLoadrAUX
{
static class Program
{
/// <summary>
/// Ponto de entrada principal para o aplicativo.
/// </summary>
[STAThread]
static void Main()
{
// check windows media player
bool wmp = checWMP();
if (wmp == false)
{
MessageBox.Show("In order to use SMLoadr AUX" + Environment.NewLine + "Windows Media Player must be installed." + Environment.NewLine + Environment.NewLine + "Go to:" + Environment.NewLine + "Control panel > Programs > Turn Windows features on/off" + Environment.NewLine + "Select Media Features from the list." + Environment.NewLine + Environment.NewLine + "Hit OK and restart. Retry again!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmSMLoadrAUX());
}
/// <summary>
/// method that verifies if windows media player is installed
/// </summary>
/// <returns>Return true if is installed</returns>
static bool checWMP()
{
bool installed = false;
string WMP_64 = "22d6f312-b0f6-11d0-94ab-0080c74c7e95"; //Windows Media Player v6.4
string WMP_7 = "6BF52A52-394A-11d3-B153-00C04F79FAA6"; //Windows Media Player v7 or later
try
{
RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Active Setup\Installed Components\{" + WMP_64 + "}");
if (Key != null)
{
installed = ((int)Key.GetValue("IsInstalled") == 1) ? true : false;
if (!installed)
{
Key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Active Setup\Installed Components\{" + WMP_7 + "}");
if (Key != null)
installed = ((int)Key.GetValue("IsInstalled") == 1) ? true : false;
}
}
}
catch (Exception ex)
{
// On excepcion we assume it's not installed
installed = false;
}
return installed;
}
}
}