private void SetNDKPath()
{
//Initialize NDK if possible.
RegistryKey rkHKCU = Registry.CurrentUser;
RegistryKey rkNDKPath = null;
string qnx_target = "";
string qnx_host = "";
try
{
rkNDKPath = rkHKCU.CreateSubKey("Software\\BlackBerry\\BlackBerryVSPlugin");
qnx_host = rkNDKPath.GetValue("NDKHostPath").ToString();
qnx_target = rkNDKPath.GetValue("NDKHostPath").ToString();
if (qnx_host == "")
{
string[] filePaths = Directory.GetFiles(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\BlackBerry Native SDK\qconfig\", "*.xml");
if (filePaths.Length >= 1)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filePaths[0]);
XmlNodeList name = xmlDoc.GetElementsByTagName("name");
XmlNodeList hostpath = xmlDoc.GetElementsByTagName("host");
XmlNodeList targetpath = xmlDoc.GetElementsByTagName("target");
qnx_target = targetpath[0].InnerText;
qnx_host = hostpath[0].InnerText;
rkNDKPath.SetValue("NDKHostPath", qnx_host);
rkNDKPath.SetValue("NDKTargetPath", qnx_target);
}
}
string qnx_config = GlobalFunctions.bbndkPathConst + @"\features\com.qnx.tools.jre.win32_1.6.0.43\jre\bin";
System.Environment.SetEnvironmentVariable("QNX_TARGET", qnx_target);
System.Environment.SetEnvironmentVariable("QNX_HOST", qnx_host);
string ndkpath = string.Format(@"{0}/usr/bin;{1}", qnx_host, qnx_config) +
System.Environment.GetEnvironmentVariable("PATH");
System.Environment.SetEnvironmentVariable("PATH", ndkpath);
}
catch (Exception ex)
{
string e = ex.ToString();
}
rkNDKPath.Close();
rkHKCU.Close();
}