Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1002 B

  1. //
  2. // NetApi.cpp
  3. //
  4. // Wrapper / helper functions that interface between real net APIs and
  5. // the Home Networking Wizard.
  6. //
  7. // Revision History:
  8. //
  9. // 9/27/1999 KenSh Created
  10. //
  11. #include "stdafx.h"
  12. #include "NetConn.h"
  13. #include "NetApi.h"
  14. #include "theapp.h"
  15. NETADAPTER* g_prgCachedAdapters;
  16. int g_cCachedAdapters;
  17. void FlushNetAdapterCache()
  18. {
  19. NetConnFree(g_prgCachedAdapters);
  20. g_prgCachedAdapters = NULL;
  21. g_cCachedAdapters = 0;
  22. }
  23. // Note: do NOT free the array that is returned!
  24. int EnumCachedNetAdapters(const NETADAPTER** pprgAdapters)
  25. {
  26. if (!theApp.IsWindows9x())
  27. {
  28. // Shouldn't be called on NT
  29. return 0;
  30. }
  31. if (g_prgCachedAdapters == NULL)
  32. {
  33. // Note: this will be leaked if FlushNetAdapterCache() is not called
  34. g_cCachedAdapters = EnumNetAdapters(&g_prgCachedAdapters);
  35. }
  36. *pprgAdapters = g_prgCachedAdapters;
  37. return g_cCachedAdapters;
  38. }