Search code examples
delphiwindows-servicesdelphi-2010msmq

Access denied in Message Queuing


I developed an application in Delphi 2010 that reads XML data from a transactional queue. It works fine if the queue is local or remote and I don't have to set permissions in both cases.

Now I have to convert that application into a Windows Service. I copied and pasted the same application into the service code, but when I try to read the queue I get the "Access denied" error. I'm doing the tests on my local machine.

Some people say that it's a matter of permissions. I found here in Stack Overflow some posts to the same problem but I didn't find the solution.

Any ideas? I'm using Windows 7 as well.


Solution

  • If you are running the application locally, you are running it under your Windows logon credentials. Services by default are launched under a different user account which may not have the same rights as your account does.

    Bring up the service manager (start->services.msc), find your service in the list, right click it and select Properties. Then select the Log On tab and change it to a specific account name/password. (Use your account name / password.) You'll then be executing the code using the same credentials so your Access Denied error should go away.