|
//
// BlueWave.Interop.Asio by Rob Philpott. Please send all bugs/enhancements to
// rob@bigdevelopments.co.uk. This file and the code contained within is freeware and may be
// distributed and edited without restriction. You may be bound by licencing restrictions
// imposed by Steinberg - check with them prior to distributing anything.
//
#include "AsioRedirect.h"
#include "InstalledDriver.h"
// we need this for registry access
using namespace Microsoft::Win32;
// and we need this for typed lists
using namespace System::Collections::Generic;
namespace BlueWave
{
namespace Interop
{
namespace Asio
{
InstalledDriver::InstalledDriver(String^ name, String^ clsId)
{
// remember the name and CLSID
_name = name;
_clsId = clsId;
}
array<InstalledDriver^>^ InstalledDriver::GetInstalledDriversFromRegistry()
{
// our settings are in the local machine
RegistryKey^ localMachine = Registry::LocalMachine;
// in the software/asio folder
RegistryKey^ asioRoot = localMachine->OpenSubKey("SOFTWARE\\ASIO");
// now read all the names of subkeys below that
array<String^>^ subkeyNames = asioRoot->GetSubKeyNames();
// create a generic list of installed drivers
List<InstalledDriver^> list = gcnew List<InstalledDriver^>();
// iterate through and get the stuff we need
for (int index = 0; index < subkeyNames->Length; index++)
{
// get the registry key detailing the driver
RegistryKey^ driverKey = asioRoot->OpenSubKey(subkeyNames[index]);
// and extract what we need
String^ name = static_cast<String^>(driverKey->GetValue("Description"));
String^ clsid = static_cast<String^>(driverKey->GetValue("CLSID"));
// ST: If the description value is not present, use the subkeyname
if (!name)
name = subkeyNames[index];
// and close again
driverKey->Close();
// add to our list
list.Add(gcnew InstalledDriver(name, clsid));
}
// and return as an array
return list.ToArray();
}
String^ InstalledDriver::ClsId::get()
{
return _clsId;
}
String^ InstalledDriver::Name::get()
{
return _name;
}
String^ InstalledDriver::ToString()
{
return _name;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a .NET architect/developer based in London working mostly on financial trading systems. My love of computers started at an early age with BASIC on a 3KB VIC20 and progressed onto a 32KB BBC Micro using BASIC and 6502 assembly language. From there I moved on to the blisteringly fast Acorn Archimedes using BASIC and ARM assembly.
I started developing with C++ since 1990, where it was introduced to me in my first year studying for a Computer Science degree at the University of Nottingham. I started professionally with Visual C++ version 1.51 in 1993.
I moved over to C# and .NET in early 2004 after a long period of denial that anything could improve upon C++.
Recently I did a bit of work in my old language of C++ and I now realise that frankly, it's a total pain in the arse.