Posts

Showing posts from March, 2023

How to check if your Windows packaged app was launched from a StartupTask in C# and VB

Image
Apps running on startup is very common in Windows these days; many apps do this in order to run in the background to provide services such as notifications or a tray/taskbar corner icon. Windows has multiple avenues apps can use to run on startup however, the concept is usually the same - apps can specify an executable to run on startup along with arguments either for all users or the current user and the executable will run when the user signs in. One of these avenues is the StartupTask feature of UWP/MISX packages. You can simply specify these in your app's manifest and your app will be able to run when the current user signs in. As a developer, you might want to write code to check if your app was launched by a startup task - this might be useful if, for example, you want your app to run in the background and not show a main window if it is launched automatically from a StartupTask. How to check if app was launched from a StartupTask The first thing we'll need to do is make

How to allow picking files from other apps in a file picker in WPF and Windows Forms/WinForms in C# and VB

Image
You may have noticed that sometimes in file pickers in Windows, you not only have the option of picking files from folders, but also have the option of picking files through other apps - like selecting a photo from your photos library using the Photos app or taking a picture with the Camera app, all right from the file picker. What you may have noticed, however, is that the options to pick from apps don't always show up. For context, here is a file picker that lets you pick from other apps: ...and here is one without the options to pick from other apps: As you can see, in the second screenshot, the options to pick files using the Camera or Photos app are gone. As a developer, you might want to show those options as they can be useful - for example, the Photos app compiles all your photos together, making it easy to look through them all instead of having to dig through folders and the Camera app can be used to allow users to take photos with the camera right from your Windows Fo