{"id":1723,"date":"2012-08-28T20:20:35","date_gmt":"2012-08-29T01:20:35","guid":{"rendered":"http:\/\/www.wiredprairie.us\/blog\/?p=1723"},"modified":"2012-08-28T20:20:36","modified_gmt":"2012-08-29T01:20:36","slug":"one-way-to-find-all-metrowindows-8-modern-ui-applications-in-c","status":"publish","type":"post","link":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1723","title":{"rendered":"One way to find all Metro\/Windows 8 Modern UI applications in C#"},"content":{"rendered":"
Running this code as an administrator, you can use the following snippet as a method for determining the nature of a process on Windows 8 and whether it would seem that the running process is running in the new Modern UI shell (metro).<\/p>\n
static void <\/span>Main(<\/span>string<\/span>[] args)\n{ \n <\/span>var <\/span>allProcesses = <\/span>Process<\/span>.GetProcesses().Where(p =>\n {\n <\/span>try\n <\/span>{\n <\/span>var <\/span>pid = p.Id;\n <\/span>var <\/span>modules = p.Modules.Cast<<\/span>ProcessModule<\/span>>()\n .Where(m => m.FileName.Contains(<\/span>"System.Runtime.WindowsRuntime"<\/span>));\n <\/span>return <\/span>modules.Count() > 0;\n }\n <\/span>catch <\/span>{ <\/span>return false<\/span>; }\n }).OrderBy(p => p.MainModule.FileName).ToList();\n \n <\/span>for <\/span>(<\/span>int <\/span>i = 0; i < allProcesses.Count(); i++)\n {\n <\/span>var <\/span>p = allProcesses[i];\n <\/span>Console<\/span>.WriteLine(<\/span>string<\/span>.Format(<\/span>"{0}. {1}"<\/span>, i, p.MainModule.FileName));\n }\n <\/span>Console<\/span>.ReadKey();\n}<\/span><\/pre>\nModern UI \/ Metro applications are protected and cannot be easily interrogated by a non-administrative process. While you can get some basics about all processes, a standard user process isn\u2019t allowed to look at the loaded modules for example.<\/p>\n
In the code above, all processes are scanned for a particular DLL. In this case, System.Runtime.WindowsRuntime. I\u2019m not 100% confident this is the best choice \u2026 there may be a few better options (or multiple that are required). (If you know of them, please leave a comment!). It did find the Modern UI \/ Metro applications running in my Windows 8 VM. <\/p>\n
Once gathered, the code just outputs the basics to the console. (The name of the host, which is WWAHost.exe apparently some times).<\/p>\n
Next step is to learn something useful via the process object.<\/p>\n","protected":false},"excerpt":{"rendered":"
Running this code as an administrator, you can use the following snippet as a method for determining the nature of a process on Windows 8 and whether it would seem that the running process is running in the new Modern UI shell (metro). static void Main(string[] args) { var allProcesses = Process.GetProcesses().Where(p => { try […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[4],"tags":[82,96],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pd5QIe-rN","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1705,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1705","url_meta":{"origin":1723,"position":0},"title":"WinRT\/Xaml\/AKA Metro DataTemplate selection based on Data Types","date":"August 20, 2012","format":false,"excerpt":"You may have noticed that WinRT does not have automatic resolution of a DataTemplate based on the data type of object added to an ItemsControl. While unfortunate as this behavior is quite handy, it\u2019s not too difficult to replicate the functionality using a DataTemplateSelector. WPF for example, could do something\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1701,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1701","url_meta":{"origin":1723,"position":1},"title":"Windows 8 WinRT\/Metro Missing UpdateSourceTrigger","date":"August 5, 2012","format":false,"excerpt":"If you\u2019ve done WPF or Silverlight programming, you may have found an occasion where using the Binding property UpdateSourceTrigger set to PropertyChanged was extremely useful. (I know I have!) It may have looked something like this: The key feature was the live updating of the\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":175,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/175","url_meta":{"origin":1723,"position":2},"title":"What’s the perfect API?","date":"May 5, 2008","format":false,"excerpt":"I was skimming a rant by someone on arstechnica about how badly messed up Win32 APIs are and how superior everything else is, when this paragraph grabbed my attention: The reason must be that no one in Microsoft actually gives a damn. Each group develops their own UI widgets in\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1524,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1524","url_meta":{"origin":1723,"position":3},"title":"Alternative to ApplicationSettings in .NET","date":"February 1, 2012","format":false,"excerpt":"After dealing with lost settings, an unclear upgrade path, and my own confusion surrounding the magic of Settings in a .NET client application, I decided to build my own. You\u2019re probably familiar with this UI in Visual Studio. It hasn\u2019t changed much since it was first created: A list of\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/02\/image.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1730,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1730","url_meta":{"origin":1723,"position":4},"title":"How to find an element in a DataTemplate in WinRT\/XAML.","date":"September 7, 2012","format":false,"excerpt":"Here\u2019s one way to find a named element in a DataTemplate in XAML in Windows 8 XAML. You might try FindName to discover it doesn\u2019t work. That\u2019s because it\u2019s not recursive. So, I created a simple extension method to do the same thing: public static class FrameworkElementExtensions { public static\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/09\/image.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1201,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1201","url_meta":{"origin":1723,"position":5},"title":"Microsoft: Make the “Metro\/Zune” look a standard. Publish it. Push it. Now.","date":"February 11, 2011","format":false,"excerpt":"Apple makes user experience inroads every day on Windows when a developer follows Apple\u2019s Human Interface Guidelines for design for a Windows Application. This post was inspired when I installed Miro this morning on my desktop PC. (Don\u2019t get me started that it opts-in a bunch of changes and a\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"SNAGHTML1c0109","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2011\/02\/SNAGHTML1c0109.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1723"}],"collection":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/comments?post=1723"}],"version-history":[{"count":1,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1723\/revisions"}],"predecessor-version":[{"id":1724,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1723\/revisions\/1724"}],"wp:attachment":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/media?parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/categories?post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/tags?post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}