c++lvalueopenprocess

lvalue required as left operand of assignment at isProcessRunning(handle)=true


i don't get what is wrong with my code, sry if it's a silly question i'm a beginner

#include <Windows.h>
#include <iostream>
#include <Winuser.h>
#include <stdint.h>


bool isProcessRunning(HANDLE process)
  {
return WaitForSingleObject( process, 0 ) == WAIT_TIMEOUT;
  }

int main(int argc, char** argv) {
    HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,FALSE,7824);
    while ( isProcessRunning(handle)=true )
    {
        //code  
    }

    return 0;
}

(line 15 col 34) [Error] lvalue required as left operand of assignment


Solution

  • A single = means assignment. For comparison you need ==.

    So what you want is

    while (isProcessRunning(handle) == true)

    or just

    while (isProcessRunning(handle))