I'll answer your question by asking you two questions:
1) What is a handle in terms of C++? What if one module thinks a handle is really a struct with two int members, while another module thinks that a handle is really a void pointer? What do you think will happen if those two modules start sharing something they both call a "handle", but the internals of the handle are different?
2) What if the application and DLL have separate "handle" managers? What happens if you create a handle in the app, and then pass this "alien" handle to the DLL that uses a separate handle manager? The DLL's handle manager will assume the handle is invalid, since the DLL's handle manager didn't create the handle.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; May 6th, 2013 at 01:35 PM.
Please see the attached sample that passes file handle to dll within the same process. The code does just fine:
Code:
D:\Temp\87>87.exe C:\hiberfil.sys
EXE: last error 32
D:\Temp\87>net helpmsg 32
The process cannot access the file because it is being used by another process.
D:\Temp\87>87.exe 87.exp
EXE: last error 2
D:\Temp\87>net helpmsg 2
The system cannot find the file specified.
D:\Temp\87>87.exe 87dll.exp
EXE: dwFlags = 0
DLL: dwFlags = 0
D:\Temp\87>87.exe 87.exe
EXE: dwFlags = 0
DLL: dwFlags = 0
But when I close handle before passing it to DLL...
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.