Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: WMP library from windows service

HTVi
TV Discussion Newsgroups

WMP library from windows service
Arindam 4/17/2007 2:16:03 PM
Hi All,
I am making a windows service which needs to access WMP library.

My code is like this.

using WMPLib;
WMPLib.WindowsMediaPlayer Player;
IWMPPlaylist mediaPlaylist;
Player = new WMPLib.WindowsMediaPlayer();
mediaPlaylist = Player.mediaCollection.getByAttribute("MediaType", "audio");

Now mediaPlaylist.count is giving 0. But my Music library contains 20 files.
I have tried this kind of code in a console application, it is working
correct there.

Is there any restriction imposed on the accessability of WMP library from
windows service ( I am running my service as administrator).
How to solve this problem?

I am using WMP 10 sdk. In the documentation Settings.mediaAccessRights to
know the access rights of WMP library and Settings.requestMediaAccessRights
to requst the desired access right.

But in my code player.settings don't have mediaAccessRights member. I don't
know why I am not able to find this member?

Thanking you in advance.

Regards
Arindam






Re: WMP library from windows service
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 4/17/2007 2:56:37 PM
From: "Arindam"

[Quoted Text]
> I am making a windows service which needs to access WMP
> library.
[...]
> Now mediaPlaylist.count is giving 0. But my Music library
> contains 20 files. I have tried this kind of code in a
> console application, it is working correct there.

The console application by default runs under the same
account as the interactive user while services usually run
under some system account. Have you configured the service
to run under the same account or to impersonate the account
in code?


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm



Re: WMP library from windows service
Arindam 4/18/2007 5:58:05 PM

Thanks a lot for your reply. I think you are right, my service is running
under system account.
Today I have done some experements and got some positive results.
I am creating my service from VS2005 C# Windows Service wizard. Then I am
adding a installer to it.In the installer account type I have set it to
NetworkService ( as my service need some network related activities). Then I
added a set-up project to it . After installing my service from
Administrative Tools->service->my service->property I opend the log on page
and logged on as administrator and started the service and it worked correct.

[Quoted Text]
>Have you configured the service
> to run under the same account or to impersonate the account
> in code?

Still I am not able to cofigure my service programatically to run under a
specific user's account.
Can you tell me the steps to do it.

Thanking you in advance.

Regards
Arindam


"Alessandro Angeli" wrote:

> From: "Arindam"
>
> > I am making a windows service which needs to access WMP
> > library.
> [...]
> > Now mediaPlaylist.count is giving 0. But my Music library
> > contains 20 files. I have tried this kind of code in a
> > console application, it is working correct there.
>
> The console application by default runs under the same
> account as the interactive user while services usually run
> under some system account. Have you configured the service
> to run under the same account or to impersonate the account
> in code?
>
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm
>
>
>
>
Re: WMP library from windows service
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 4/18/2007 6:24:14 PM
From: "Arindam"

[Quoted Text]
> Still I am not able to cofigure my service
> programatically to run under a specific user's account.
> Can you tell me the steps to do it.

Read the docs for System.ServiceProcess.ServiceAccount.User.

If you want to run your service under whatever privileged
account and only impersonate a specific user while accessing
the user's media library, take a look at
System.Security.Principal.WindowsIdentity.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen