| 发表于:2007-07-13 20:38:561楼 得分:0 |
查msdn:用法如下 the duplicatehandle function duplicates an object handle. bool duplicatehandle( handle hsourceprocesshandle, // handle to the source process handle hsourcehandle, // handle to duplicate handle htargetprocesshandle, // handle to process to duplicate to lphandle lptargethandle, // pointer to duplicate handle dword dwdesiredaccess, // access for duplicate handle bool binherithandle, // handle inheritance flag dword dwoptions // optional actions ); parameters hsourceprocesshandle handle to the process with the handle to duplicate. windows nt: the handle must have process_dup_handle access. hsourcehandle handle to duplicate. this is an open object handle that is valid in the context of the source process. for a list of objects whose handles can be duplicated, see the following remarks section. htargetprocesshandle handle to the process that is to receive the duplicated handle. the handle must have process_dup_handle access. lptargethandle pointer to a variable receiving the value of the duplicate handle. this handle value is valid in the context of the target process. if lptargethandle is null, the function duplicates the handle, but does not return the duplicate handle value to the caller. this behavior exists only for backward compatibility with previous versions of this function. you should not use this feature, as you will lose system resources until the target process terminates. dwdesiredaccess specifies the access requested for the new handle. this parameter is ignored if the dwoptions parameter specifies the duplicate_same_access flag. otherwise, the flags that can be specified depend on the type of object whose handle is being duplicated. for the flags that can be specified for each object type, see the following remarks section. note that the new handle can have more access than the original handle. binherithandle indicates whether the handle is inheritable. if true, the duplicate handle can be inherited by new processes created by the target process. if false, the new handle cannot be inherited. dwoptions specifies optional actions. this parameter can be zero, or any combination of the following flags: value meaning duplicate_close_source closes the source handle. this occurs regardless of any error status returned. duplicate_same_access ignores the dwdesiredaccess parameter. the duplicate handle has the same access as the source handle. return values if the function succeeds, the return value is nonzero. if the function fails, the return value is zero. to get extended error information, call getlasterror. | | |
|