さて、C#で書いた次のクラスライブラリがあります。
public class Program
{
public void GetProductID(string location, out string productId)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
ManagementObjectCollection collection = searcher.Get();
var item = new Win32Product();
//var crap = (collection as IEnumerable<ManagementObject>).Where(o => o["InstallLocation"].ToString().StartsWith(location));
foreach (ManagementObject obj in collection)
{
try
{
item = new Win32Product();
item.IdentifyingNumber = (string)obj["IdentifyingNumber"];
item.InstallLocation = (string)obj["InstallLocation"];
item.Name = (string)obj["Name"];
}
catch
{ } //shut up. I know it's an empty catch block. Its fine.
//If there are exceptions thrown, I don't want the data, I just
//want to keep running.
}
productId = item.ProductID.ToString();
}
}
public class Win32Product
{
//properties
}
それほど多くはありませんGetProductId()
。特定のディレクトリの下にインストールされているプログラムを検索するだけです。他の場所でテストすれば問題なく動作しますが、installshieldから(制御イベントとして)実行すると失敗します(戻り値3)。
漠然とした質問のようなものだと思いますが、なぜGetProductInfo()
installshieldから失敗するのでしょうか。