code_junkie

How to replace WinAPI functions calls in the MS VC++ project with my own implementation (name and parametrs set are the same)?

Nov 10th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. namespace Bluetooth
  2. {
  3. void CreateFile(/*params*/);
  4. void etc...
  5. }
  6.  
  7. if (::CreateFile(...))
  8. {
  9. }
  10.  
  11. if (Bluetooth::CreateFile(...))
  12. {
  13. }
  14.  
  15. #define CreateFile MyCreateFile
  16.  
  17. HRESULT MyCreateFile(whatever the params are);
  18.  
  19. #undef CreateFile
  20. HRESULT MyCreateFile(NobodyCanRememberParamListsLikeThat params)
  21. {
  22. if (InputIsNormalFile())
  23. CreateFile(params);
  24. else
  25. // do your thing
  26. }
Add Comment
Please, Sign In to add comment