关键是GetHandleInformation函数
GetHandleInformation函数原型:
BOOLGetHandleInformation(HANDLEhObject,PDWORDpdwFlags);
Thisfunctionreturnsthecurrentflagsettingsforthespecifiedhandlein
theDWORDpointedtobypdwFlags.Toseeifahandleisinheritable,
dothefollowing:
DWORD dwFlags;
GetHandleInformation(hObj, &dwFlags);
BOOL fHandleIsInheritable = (0 != (dwFlags & HANDLE_FLAG_INHERIT));