Programmatically Change Windows 10 Lock Screen Background (on Desktop) - c#

How can I programmatically change/set the lock screen background image (using VB.NET, C# or Visual C++)? I am using Win 10 Pro and have Visual Studio 2017 Pro.
I've had a look online but most solutions don't seem to work. For example:
Both Change Win 10 Lockscreen Image Mutiple Times C# WPF and Change Windows Lock Screen background image in C# provide sample code but the imports System.Windows.Media.Imaging, Windows.Storage, Windows.Storage.Streams, Windows.System.UserProfile cannot be found when I paste the code. Do I need to add specific references?
Lock screen personalization sample looks very promising but upon opening the solution/project file, Visual Studio throws an error saying that the provided format is unreadable.
Most sources (also Windows Dev Center - LockScreen Class) seem to suggest
Windows.System.UserProfile.LockScreen.SetImageFileAsync(file);
but I am apparently missing the specific namespace/import/package to make it run.
Any help would be appreciated.

I've found an easier way using this question Windows 10 Pro lockscreen mass change. All I need to do is set the registry entries under
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP
DesktopImagePath
DesktopImageUrl
LockScreenImagePath
LockScreenImageUrl
to the path of the desired picture, which works without UWP or WPF.

As alluded to in my comment, the Windows.System.UserProfile namespace is part of the UWP platform and requires having the Windows 10 SDK installed to utilize.
You can install the SDK by running the Visual Studio Installer, click "Modify" and then choose the "Universal Windows Platform development" workload, or choose the SDK from the list of "Individual Components". More details can be found here.
You may be able to use the library from a desktop .NET app as mentioned in this question How to Interop with Windows Runtime in .NET 4.5 and this link from the answer, but there's no guarantee that Microsoft will continue to allow that so you're probably better off developing using the UWP.
There is a sample from Microsoft for Lock Screen Personalisation on Windows 10 on GitHub here.

ImageGlass, an open-source image viewer, provides a command-line utility to change the Windows LockScreen image: igcmdWin10.exe
Usage: igcmdWin10.exe setlockimage "C:\image.jpg"
Extract it from the .zip release on their Github repository
ImageGlass official documentation for reference.

Related

Setting UWP Target System

I'm building an UWP application using Visual Studio 2017 Community Edition.
Everytime I create a new UWP project, I cannot select Target version lower than version 1809. See below pic.
My problem is, my current windows 10 version is 1803, and when I want to update my windows 10 to 1809, I found that 1809 is somehow not available according to this post in windows forum below:
Link to forum
What happen then, when ever I want to design and preview my UWP app, I cannot render all controllers within the page. Like below pic.
My question are:
How can I resolve this besides waiting for update 1809 avail?
Is there anyway I can change the TARGET VERSION of my app? so I can have better experience in coding my app?
Thanks
If I understand correctly, you have to install older SDK for Min version before you start work.
You can find all versions of it on this page and download them Windows SDK and emulator archive .
for example If you want it to be at least compatible with the Windows 10 Anniversary Update then you should download and install SDK (ver. 10.0.14393.795)

What do I really need to install into VS 2015, to create a simple universal app?

I'll try to be concrete so this doesn't get tagged as a discussion question.
I'm a complete programming beginner learning C#, and one exercise includes creating a universal win10 app. Except my version of Visual Studio 2015 doesn't have this type of template pre-installed, so I clicked to download it. Turns out it's 12 Gb.
My question is whether I can opt out of some of the things that Microsoft want to install, specifically "Common tools for Visual C++ 2015". I tried unchecking it, but then it automatically also removed "Tools (1.4) and Windows 10 SDK (10.0.10586)", which seems a lot more important. So maybe I need tools for C++, even though I'm not using C++?
I notice there is another one you can check, called "Windows 10 SDK (10.0.10240)", and I thought perhaps I can choose that one instead. This one allows me to uncheck C++, which gives me back 6Gb of harddrive.
Since I'm just trying to learn, I don't need the app to be compatible with win8, I don't need to emulate a phone or Xbox or what have you. I just need to make an app with a GUI, to see how it's done.

XAML previewer for Visual Studio 2015. Is it available or are there any third party alternatives?

I am coming from android studio and am really missing the preview feature when editting XML code.
The Xamarin website says this:
https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-previewer/
I find it essential to use the XML preview because I am still a beginner and learning.
Is there any way this can be done? Perhaps any third party apps if they exist?
Thanks In advance
There some alternatives to Xamarin's own XAML previewers, but it is unclear whether those third parter alternatives would support XAML themes.
Gorilla Player
enter image description here
This one is particularly good for previewing the XAML live simultaneously across multiple platform. I think its available on windows but the level of integration with visual studio remains unclear. However, as their download page contains link for windows, it should support it.
You can access it from this link:
http://gorillaplayer.com
XenForms
XenForms is another promising Xamarin.Forms. You can Load, Edit, and Save XAML. This is the first WYSIWYG UI designer for Xamarin.Forms. This tool definitely support windows as a developing platform and windows phones. Unfortunately, it does NOT support drag and drop. Another great feature is that is it has some support for c# user interface as well as the XAML markups.www.xenforms.com
You can check Xamarin's own previewer which is integrated with Visual Studio. Please update your xamarin to latest installation. You may also need to rebuild the solution and then open/reopen the XAML file for preview. For details please check my blog post here.

Windows Mobile & other Extensions for the UWP - which version should I use

I have already got to know that in order to obtain DeviceId I should add reference to my project - "Windows Mobile Extensions for the UWP" this SDK comes with Visual Studio and is available in References Manager under Windows Universal/Extensions position.
However there are two positions like that on the list, they come with different versions - 10.0.10240.0 and 10.0.10586.0.
Which one of them should I use? Are there any differences that I should be aware of, or should I just keep using newer one? Are they related to the windows build number on the machine I want to run my app?
A Universal Windows Platform project can use feature detection to take advantage of APIs available on a platform version "2" and still run on platform version "1", the same way it can run on desktop, mobile or IoT with specific user experience for each platform.
This is how to deal with feature detection (and not version detection)
https://blogs.windows.com/buildingapps/2015/09/15/dynamically-detecting-features-with-api-contracts-10-by-10/
Check how to setup your project properties
https://msdn.microsoft.com/en-us/library/8x480de8.aspx
In the Solution Explorer, right click on References and add the Windows Mobile Extensions for the UWP.
You may still need to remove the older SDK reference and do a clean build, but this resolved that error for me on the samples.

Metro Style Application code file missing ReadLine feature?

I started programming a small "Metro Style" project in Visual Studio 2011, the one that was released in Windows Developer Preview. It combines XAML for the design and C# (in my project) for the code-behind.
System.Console.WriteLine ----> System.Diagnostics.Debug.WriteLine,
System.Console.ReadLine ----> ?.........
So are these features actually missing / disabled
Thanks in advance.
In regard to Console.*: In Windows 8 Metro there is no such concept like a console window. Methods related to a console make no sense. According to the API reference on dev.windows.com ( http://msdn.microsoft.com/en-us/library/windows/apps/system.diagnostics.debug(v=vs.110).aspx ) System.Diagnostics.Debug.WriteLine is available. The supported platforms do list Windows 8 Consumer Preview, so I assume this feature isn't yet available on the Developer Preview. I would recommend that you update to the latest build avaiable. Remember: The Developer Preview was in a very early stage and plenty of things have changes since then.

Categories

Resources