关键是GetHandleInformation 函数
GetHandleInformation 函数原型:
BOOL GetHandleInformation(HANDLE hObject, PDWORD pdwFlags);
This function returns the current flag settings for the specified handle in
the DWORD pointed to by pdwFlags. To see if a handle is inheritable,
do the following:
DWORD dwFlags; GetHandleInformation(hObj, &dwFlags); BOOL fHandleIsInheritable = (0 != (dwFlags & HANDLE_FLAG_INHERIT));