stavros141 0 Newbie Poster

Hello there, I recently decide to learn and code Windows Services, After I learned the bare
basic I thought I would make a program that logs the users program usage every 60 seconds
I have coded the same thing without putting it in a service but apparently Services work differently
could somebody help please?

//hTarget and hTemp are global variables
void UpdateForegroundHWND()
{
    hTemp = GetForegroundWindow(); 
    if(hTemp == NULL) // If no foreground Window record no activity
    {
        WriteToLog("No Window Currently Used...\n");
        return;
    }
    if(hTarget == NULL) // if target is 0 the set the target as the Handle to the Foreground WD
        hTarget = hTemp; 
    if(hTarget != hTemp) // if target handle != temp handle set target to temp
        hTarget = hTemp;
}

Thank you very much, all help is appreciated.

Disclaimer, I know it seems weird but I am not writing malware or something. It is just for fun & learning

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.