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.

77 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. setupapi.hpp
  5. Abstract:
  6. Wrapper class library for setup api
  7. Author:
  8. Vijay Jayaseelan (vijayj) 04 Aug 2000
  9. Revision History:
  10. None
  11. --*/
  12. #include <setupapi.hpp>
  13. #include <queue.hpp>
  14. //
  15. // InfFile<T>'s static data
  16. //
  17. InfFileW::GetInfSectionsRoutine InfFileW::GetInfSections = NULL;
  18. HMODULE InfFileW::SetupApiModuleHandle = NULL;
  19. ULONG InfFileW::SetupApiUseCount = 0;
  20. InfFileA::GetInfSectionsRoutine InfFileA::GetInfSections = NULL;
  21. HMODULE InfFileA::SetupApiModuleHandle = NULL;
  22. ULONG InfFileA::SetupApiUseCount = 0;
  23. //
  24. // Helper methods
  25. //
  26. std::ostream&
  27. operator<<(std::ostream &os, PCWSTR rhs) {
  28. return os << std::wstring(rhs);
  29. }
  30. std::string&
  31. ToAnsiString(std::string &lhs, const std::wstring &rhs) {
  32. ULONG Length = rhs.length();
  33. if (Length){
  34. DWORD Size = 0;
  35. CHAR *String = new CHAR[Size = ((Length + 1) * 2)];
  36. if (::WideCharToMultiByte(CP_ACP, 0, rhs.c_str(), Length + 1,
  37. String, Size, 0, 0)) {
  38. lhs = String;
  39. }
  40. delete []String;
  41. }
  42. return lhs;
  43. }
  44. std::ostream&
  45. operator<<(std::ostream &os, const std::basic_string<WCHAR> &rhs) {
  46. std::string AnsiStr;
  47. ToAnsiString(AnsiStr, rhs);
  48. return (os << AnsiStr);
  49. }