Sorry for the late response.
Although you already fixed your problem by working around it, I got one more question:
That typedef THandle<HANDLE> Handle in your solution, did you also use that in your original code, i.e. at this point:
processHandle and processHandle_ are of the type THandle<HANDLE> in fact?
If this is the case, that's the reason why your assignment operator is not called. You defined it as
Code:
HandleType& operator=(const HandleType& value) {
DuplicateHandle(reinterpret_cast<HandleType>(-1), value, reinterpret_cast<HandleType>(-1), &_value, 0, false, DUPLICATE_SAME_ACCESS);
return *this;
}
meaning that it will be called, if you try to assign a HandleType (which is HANDLE in your case) to your handle wrapper. But if you assign a handle wrapper to another one, the default assignment operator will be used.
Code:
THandle& operator=(const THandle& other) {
DuplicateHandle(reinterpret_cast<HandleType>(-1), other._value, reinterpret_cast<HandleType>(-1), &_value, 0, false, DUPLICATE_SAME_ACCESS);
return *this;
}
would be correct.