Development isn't about trying to "find some code" - it's about creating that code from the available tools.
And while this isn't a job I'd recommend for a beginner - there are a lot of complexities here, starting with the Database and working up - if you do some reading you may be able to work it out. Probably going to take you a while though...
How to connect SQL Database to your C# program, beginner's tutorial[
^]
Get List of Installed Applications of System in C#[
^]
They will give you the basics, but they won't tell you if "someone is using the computer" - for that you need to sit down and think good and hard about what "using the computer" means to you.