Question

qingcai518 on Mon, 30 Jun 2014 07:12:30


How can I update LockScreen image use LockScreen.SetImageFileAsync in Windows Service Project?

I create a Windows Service Project and wanna update LockScreen image with my pic,

but LockScreen.SetImageFileAsync & LockScreen.SetImageStreamAsync doesn't work for me.

namespace MyService { class Service { private Thread thread; private AppUtils appUtils; public void Start() { try { thread = new Thread(new ThreadStart(LaunchServer)); thread.IsBackground = true; thread.Start(); } catch (Exception exp) { } } public void Stop() { try { if (thread != null) { thread.Abort(); thread = null; } } catch (Exception exp) { EventLog.WriteEntry(EventLogTitle, exp.ToString(), EventLogEntryType.Error); } } async private void LaunchServer() { try { StorageFile newImageFile = await KnownFolders.PicturesLibrary.GetFileAsync("image001.png"); await LockScreen.SetImageFileAsync(newImageFile); } catch (Exception exp) { } }

}

}



Sponsored



Replies

qingcai518 on Mon, 30 Jun 2014 07:16:23


I have already set the <TargetPlatformVersion>8.0</TargetPlatformVersion> in my *.csproj file and add references for the project like this :

1. Windows

2. System.Runtime.dll

3. System.Threading.Tasks.dll

4. System.Runtime.InteropServices.WindowsRuntime.dll

5. System.Runtime.WindowsRuntime.dll

qingcai518 on Mon, 30 Jun 2014 07:25:10


and it can work when project type is Windows Form Project

Jitta on Mon, 30 Jun 2014 07:30:44


check account which process is running when windows form, process is running on your account when windows service, who?

qingcai518 on Mon, 30 Jun 2014 07:59:38


Hi, Jitta.

I checked and the result is this:

When windows form : my login account.

When windows service: System.

They're different.

But I don't known what to do next, can you give me some hint?

Jitta on Mon, 30 Jun 2014 13:18:28


you can change account but, sorry I forget where is property sheet From services in control panel, you can change account

星 睦美 on Tue, 01 Jul 2014 00:51:35


Hello qingcai518,

Thank you for your posting. This forum is Japanese MSDN forum.
If you have any questions further, I 'd like to suggest you post your question on English MSDN forum.

http://social.msdn.microsoft.com/Forums/en-us/home

Mutsumi Hoshi - Moderator


フォーラム オペレーター 星 睦美 - MSDN Community Support