private void InitFromHostApp() { ProgramArgumentCollection coll = new ProgramArgumentCollection(); if (coll.ArgumentExists("--program")) { parentExecutable = coll["--program"]; } else { string wmiQuery = string.Format("SELECT * FROM Win32_Process WHERE ProcessId = {0}", Process.GetCurrentProcess().Id); ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", wmiQuery); ManagementObjectCollection.ManagementObjectEnumerator mColl = searcher.Get().GetEnumerator(); mColl.MoveNext(); parentExecutable = (string)mColl.Current["ExecutablePath"]; } FileVersionInfo info = FileVersionInfo.GetVersionInfo(parentExecutable); if (info.ProductName == null || info.ProductName == string.Empty) { appName = Path.GetFileNameWithoutExtension(parentExecutable); } else { appName = info.ProductName; } Text = "LangLib - Database configuration [" + appName + "]"; }
/// <summary> /// Checks if the program should run database configuration tool. /// <para/>This is indicated by command line argument "--configureLang". /// </summary> /// <returns>True if a database configuration should be run, otherwise false.</returns> public static bool ShoudConfigure() { ProgramArgumentCollection args = new ProgramArgumentCollection(); return(args["--configureLang"] == "1"); }