INTERACT FORUM

Windows => Plug-in Development => Topic started by: pahunt on November 11, 2014, 10:17:19 am

Title: Checking library type using automation
Post by: pahunt on November 11, 2014, 10:17:19 am
Is there a way to check if the current library is a local one or a library client using the automation interface?
Title: Re: Checking library type using automation
Post by: glynor on November 13, 2014, 11:24:28 pm
Yep.  Easy-peasy.

Code: [Select]
/// <summary>
/// Tests to see if MC is running with a network Library or not.
/// </summary>
/// <returns></returns>
public static Boolean IsNetworkLibrary()
{
string libraryName = null, libraryPath = null;
MCCore.Instance.GetLibrary(ref libraryName, ref libraryPath);
if (libraryName == null || libraryPath == null)
throw new InvalidOperationException("Media Center does not appear to have a valid Library loaded.");
else if (libraryPath.IndexOf("\\Connected Library\\", StringComparison.OrdinalIgnoreCase) > 0)
return true;
else
return false;
}

MCCore.Instance is, in this case, just a reference to the "root" IMJAutomation interface.
Title: Re: Checking library type using automation
Post by: pahunt on November 14, 2014, 04:36:51 am
That looks perfect, thanks Glynor :)