Pass a value/indicator between projects in DOTNET (C#)

Mar 27 2011 6:05 PM

Hi,

I have a question about passing a value/indicator between projects in DOTNET (VS2010 & C#).  Overall these 2 projects create an application which continuously runs on users computers Windows XP, Vista, & Win 7).  There is a main project and a Windows service project – the main project runs as an application when a user is logged into their computer, while the service project runs when the user logs out (when computer is back at the login screen).  I need to pass a value/indicator between the main project and the service project, so that when the user logs off then if the value/indicator is set by the main project then the service project will recognise this, perform a task and reset/remove this so that it is only called one time (i.e. until the next time that the user logs into the computer and the value/indicators set again.

So far, I have been creating an files (XML) with a value, and saving this as a file on the (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) directory, so as to save this to the users MyDocuments directory.  I had hoped to then access this when the user logs off (i.e. the last user to log off).  However, I can't get the service part of my application to access this using the same special folder.

Overall, I am trying to find out if there is any way for a service project to access an XML file the MyDocuments (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) folder of the last user who was logged in, and then if the services project could modify this file to reset this value (as I just want this aspect called once when the user logs out).  Alternatively, is there a different or better way to set a value/indicator from an application when the user is logged in, and then for a service project to access this when the user logs out and modify/reset it so that it isn't called continuously.  From what I can see, Windows 7 seems to be tricky for permissions, so as to allow the service to both read a file and then modify it.

Hope this makes sense and any help/advice appreciated.


Answers (8)