I have a little problem with the SetParent API. On my local system, it works fine. But when I put the program on a virtual machine, the handle does not work properly.
Here's what I've got in my code:
var si = new ProcessStartInfo(filetoexec, args);
si.UseShellExecute = true;
si.WindowStyle = ProcessWindowStyle.Normal;
var pr = new Process();
pr.StartInfo = si;
pr.StartInfo.CreateNoWindow = true;
pr.StartInfo = si;
pr.StartInfo.FileName = filetoexec;
pr.StartInfo.Arguments = args;
pr.EnableRaisingEvents = true;
pr.Exited += ProcessExited;
pr.Start();
pr.WaitForInputIdle(1000);
IntPtr rValue = SetParent(pr.Handle, formHandle); //rValue = Handle Verification
After this, I write out a log file which returns my parent handle, the process handle and my handle verification which is the rValue. Not sure if this has anything to do with it, but these processes that I am calling have been written in Cobol. Anyway, on my local machine I get something like the following: Parent Handle: 723138, Cobol Handle: 1700, Handle Verification: 460364 and so on with all the processes that I open. On the virtual machine on the other hand, the parent handle and cobol handles are fine. But the Handle Verification always returns 0. Would anybody know why that would be? Am I missing something in my code?
Edit:
formHandle = parent handle