アセンブリ情報まわり

アセンブリ情報を使うとファイル埋め込みとか色々でけて便利!


//現在実行中のアセンブリを取得
Assembly thisExe = Assembly.GetExecutingAssembly();
こうやって取得したあと、

foreach (string resourceName in thisExe.GetManifestResourceNames())
{
Console.WriteLine(resourceName);
}
これでリソース名げった〜。何故かハンドルが欲しい時は、

//ハンドル取得
Module[] ms = thisExe.GetModules();
IntPtr hInstance = Marshal.GetHINSTANCE(ms[0]);
Console.WriteLine(hInstance.ToString());
こんなのでいけますの。