Using MCI in a service, possible ?
Hi !
I just started developing in Visual C++ and first thing I do is developing a service :) My Problem is I do have the logitech internet keyboard(old) and logitech didn't develop drivers for win2k. So I am doing it myself.
Everything worked fine, getting the special keys and stuff...now my Problem is that I can open the cd audio drive via mcisendcommand in a normal program, but once I try doing it in a service, I get the CANNOT_LOAD_DRIVER error when issueing the MCI_OPEN. The code I use in a normal program and in the service is the same :
MCI_OPEN_PARMS openparms;
memset(&openparms,0,sizeof(openparms));
openparms.lpstrDeviceType=(LPCTSTR)MCI_DEVTYPE_CD_AUDIO;
TCHAR drive[4];
strcpy(drive,"I:");
openparms.lpstrElementName=drive;
DWORD dwError = mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID|MCI_OPEN_ELEMENT| MCI_OPEN_SHAREABLE,(DWORD)&openparms);
I would appreciate any kind of help.
[971 byte] By [
kenobi] at [2007-11-17 19:15:58]

# 1 Re: Using MCI in a service, possible ?
The error returned is MCIERR_CANNOT_LOAD_DRIVER to be exact. Not CANNOT_LOAD_DRIVER, sorry.
kenobi at 2007-11-10 3:39:39 >

# 2 Re: Using MCI in a service, possible ?
This may or may not help. But, I'll give it a try.
Why would you add the program as a service? Either you should replace the device driver (a lot of trouble) or run the program whenever a user logs on. This is the only time you need it running anyway.
Running as a service defaults to run under the SYSTEM account of the computer. That is not the best security context to run under. And may conflict with the user's security context.
What model is your keyboard? Because www.logitech.com appears to have full support for W2K and XP. You should check there again.
# 3 Re: Using MCI in a service, possible ?
Thx Kdr Kane,
It might be better to do it in an application...but by now I did so much research that I wanna get it running :) If it doesn't work in 2 days, then I will do it as an application.
Well...I do have the Y-SB3, and I just found - after searching for a while - the article I read about 2 years ago :
--
Due to architectural changes in the OS, Logitech does not have a version of Key Commander software that is compatible with Windows 2000. Logitech does not plan to release a compatible version because these keyboards are no longer manufactured and no further software development has been planned.
--
They even offer special prices for US and canadian people for new keyboards...unfortunately, I don't come from there :)
I had one success...I managed to get around the MCI problem, now I can open the drive via a DeviceIoControl command...but now I am actually encountering the same problem in the service again. I don't understand it. People always say the LocalSystem account has all privileges possible, but a simple
HANDLE hDevice = CreateFile(\\\\.\\I:,
GENERIC_READ,
FILE_SHARE_READ|
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
returns with "access denied". I tried to let the service run as LocalSystem, administrator and the account i am currently using as well. It doesn't work.
Thanks for any kind of help.
kenobi at 2007-11-10 3:41:40 >

# 4 Re: Using MCI in a service, possible ?
I don't want to lead you down the wrong path, but I have a suggestion.
If you open gpedit.msc, you will be able to adjust the rights to the account you wish to use.
Computer Configuration
--> Windows Settings
--> Security Settings
---> Local Policies
-----> User Rights Assignment
------> Log on as a service
You can give any account the right to Log on as a service.
That should remove your access denied error.
It's not a good solution for any situation other than personal use.
# 5 Re: Using MCI in a service, possible ?
Hi !
My problem is not that the service doesn't start up. It does, but this CreateFile command fails with a GetLastError() of "access denied". The LocalSystem account always has the right to log on as a service, and when I changed the user to administrator, my Win2k said that the administrator is gonna be assigned the right to log on as a service, so I didn't even have to do that. Nevertheless, my CreateFile command fails and I have no clue why. To me, it seems to be one of the most basic actions anyone wants to do in its service.
kenobi at 2007-11-10 3:43:51 >

# 6 Re: Using MCI in a service, possible ?
Just in case anyone is interested...
It seems that the problem is, that the DACL in the security descriptor of my CD ROM drives CDROM0 and CDROM1 doesn't contain the system and the administrator neither. All that's in there is the SID of the current logon session, meaning that only the guy that is currently logged on can use the CDROM drives. I tried to add the system to the DACL without success, but I am sure somewhere there is the problem.
kenobi at 2007-11-10 3:44:49 >
