WindowsFormアプリケーションで自身のGUIDを取得するときは
var assem = System.Reflection.Assembly.GetExecutingAssembly(); var attr = (System.Runtime.InteropServices.GuidAttribute)Attribute.GetCustomAttribute(assem, typeof(System.Runtime.InteropServices.GuidAttribute)); var guid = attr.Value;
このようにして取得できますが、
実行中の外部アプリケーションのGUIDを取得するにはどうすればいいのでしょうか。
試しに、プロセスからGUIDが取得できるかどうか試してみようと思い、以下のようなコードを上のコードに続いて記述しました。
var assem = System.Reflection.Assembly.GetExecutingAssembly(); var attr = (System.Runtime.InteropServices.GuidAttribute)Attribute.GetCustomAttribute(assem, typeof(System.Runtime.InteropServices.GuidAttribute)); var guid = attr.Value; Console.WriteLine("My Guid:{0}", guid.ToString()); System.Diagnostics.Process Myprocess = System.Diagnostics.Process.GetCurrentProcess(); Console.WriteLine("My Guid2:{0}", Myprocess.GetType().GUID.ToString());
このようにしてみましたが、出力された2つのGUIDが違っていたのでだめでした。
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/02 23:25
2017/02/03 04:21
2017/02/13 00:02