You should use the green 'Improve question' to add your code to the question rather than posting it as comment.
I tried to do it for you, but it can't be properly formatted (indented) because the code as posted in the comment would not compile by commenting the for loop.
However, you are doing
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS,FALSE, cProcesses);
passing
cProcesses
(number of processes) rather a valid process ID which results in an error 87.
You will not see this error after the above call because you are not checking your
process
variable there but your
cProcesses
variable!
Then you are passing the
process
variable (which is probably NULL) to
GetPackageFullName
resulting in another error 87.