Hi this is my code that prints the physical memory used by some process displayed in bytes , when i am converting bytes into kb by google converter. The value shown in task manager for memory usage is less than output given by my code. Also i want to know the Cpu used by the same process ? I found this question on Stack overflow,CPU USAGE that provides guidance in knowing cpu usage,but i want to know CPU usage for some Particular process id ,instead of current process as mentioned in my code, Can i achieve the same with the code provided.
Any guidance would be appreciated.
int main( void )
{
    HANDLE hProcess;
    PROCESS_MEMORY_COUNTERS pmc;
    DWORD processID = 4696;
    // Print information about the memory usage of the process.
    hProcess = OpenProcess(  PROCESS_QUERY_INFORMATION |
                                    PROCESS_VM_READ,
                                    FALSE, processID );
    if (NULL == hProcess)
        return 1;
    if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
    {
        printf( "\tWorkingSetSize: %u\n", pmc.WorkingSetSize );
    }
    CloseHandle( hProcess );
    return 0;
}
 
     
    