def wingetppid(pid):
	''' Get get parent process pid for process `pid`
	'''
	ppid = None
	hProcessSnap = c_void_p(0)
	hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS , 0 )

	pe32 = PROCESSENTRY32()
	pe32.dwSize = sizeof( PROCESSENTRY32 )
	ret = Process32First( hProcessSnap , pointer( pe32 ) )

	while ret:
		if pe32.th32ProcessID == pid:
			ppid = pe32.th32ParentProcessID
		ret = Process32Next( hProcessSnap, pointer(pe32) )
	CloseHandle(hProcessSnap)
	return ppid
 Get get parent process pid for process `pid`
	
recipes/Python/578133_Get_parent_process_pid_win32/recipe-578133.py