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.

140 lines
4.0 KiB

  1. //
  2. // MODULE: Launchers.cpp
  3. //
  4. // PURPOSE: All of the functions here launch a troubleshooter or
  5. // do a query to find if a mapping exists.
  6. //
  7. // PROJECT: Local Troubleshooter Launcher for the Device Manager
  8. //
  9. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  10. //
  11. // AUTHOR: Richard Meadows
  12. //
  13. // ORIGINAL DATE: 2-26-98
  14. //
  15. //
  16. // Version Date By Comments
  17. //--------------------------------------------------------------------
  18. // V0.1 - RM Original
  19. ///////////////////////
  20. #include <windows.h>
  21. #include <windowsx.h>
  22. #include <winnt.h>
  23. #include "TSLError.h"
  24. #include <TSLauncher.h>
  25. #include "LaunchServ.h"
  26. #include <comdef.h>
  27. #include "Launchers.h"
  28. #include "tsmfc.h"
  29. #include <stdio.h>
  30. #include <string.h>
  31. // LaunchKnownTS: Launches the trouble shooter to a specified
  32. // network, problem node, and can also set nodes.
  33. DWORD LaunchKnownTSA(ITShootATL *pITShootATL, const char * szNet,
  34. const char * szProblemNode, DWORD nNode, const char ** pszNode, DWORD* pVal)
  35. {
  36. HRESULT hRes;
  37. CHAR szValue[512];
  38. DWORD dwResult = TSL_ERROR_GENERAL;
  39. hRes = pITShootATL->ReInit();
  40. // Set the network and problem node.
  41. _bstr_t bstrNet(szNet);
  42. _bstr_t bstrProblem(szProblemNode);
  43. hRes = pITShootATL->SpecifyProblem(bstrNet, bstrProblem, &dwResult);
  44. if (TSL_SERV_FAILED(hRes))
  45. return TSL_ERROR_OBJECT_GONE;
  46. if (TSLIsError(dwResult))
  47. return dwResult;
  48. // Set the nodes
  49. for (DWORD x = 0; x < nNode; x++)
  50. {
  51. sprintf(szValue, "%ld", pVal[x]);
  52. _bstr_t bstrNode(pszNode[x]);
  53. _bstr_t bstrVal(szValue);
  54. hRes = pITShootATL->SetNode(bstrNode, bstrVal, &dwResult);
  55. if (TSL_SERV_FAILED(hRes))
  56. return TSL_ERROR_OBJECT_GONE;
  57. if (TSLIsError(dwResult))
  58. return dwResult;
  59. }
  60. hRes = pITShootATL->LaunchKnown(&dwResult);
  61. if (TSL_SERV_FAILED(hRes))
  62. dwResult = TSL_ERROR_OBJECT_GONE;
  63. return dwResult;
  64. }
  65. DWORD LaunchKnownTSW(ITShootATL *pITShootATL, const wchar_t * szNet,
  66. const wchar_t * szProblemNode, DWORD nNode, const wchar_t ** pszNode, DWORD* pVal)
  67. {
  68. HRESULT hRes;
  69. WCHAR szValue[512];
  70. DWORD dwResult = TSL_ERROR_GENERAL;
  71. hRes = pITShootATL->ReInit();
  72. // Set the network and problem node.
  73. _bstr_t bstrNet(szNet);
  74. _bstr_t bstrProblem(szProblemNode);
  75. hRes = pITShootATL->SpecifyProblem(bstrNet, bstrProblem, &dwResult);
  76. if (TSL_SERV_FAILED(hRes))
  77. return TSL_ERROR_OBJECT_GONE;
  78. if (TSLIsError(dwResult))
  79. return dwResult;
  80. // Set the nodes
  81. for (DWORD x = 0; x < nNode; x++)
  82. {
  83. swprintf(szValue, L"%ld", pVal[x]);
  84. _bstr_t bstrNode(pszNode[x]);
  85. _bstr_t bstrVal(szValue);
  86. hRes = pITShootATL->SetNode(bstrNode, bstrVal, &dwResult);
  87. if (TSL_SERV_FAILED(hRes))
  88. return TSL_ERROR_OBJECT_GONE;
  89. if (TSLIsError(dwResult))
  90. return dwResult;
  91. }
  92. hRes = pITShootATL->LaunchKnown(&dwResult);
  93. if (TSL_SERV_FAILED(hRes))
  94. dwResult = TSL_ERROR_OBJECT_GONE;
  95. return dwResult;
  96. }
  97. DWORD Launch(ITShootATL *pITShootATL, _bstr_t &bstrCallerName,
  98. _bstr_t &bstrCallerVersion, _bstr_t &bstrAppProblem, short bLaunch)
  99. {
  100. HRESULT hRes;
  101. DWORD dwResult = TSL_ERROR_GENERAL;
  102. hRes = pITShootATL->Launch(bstrCallerName, bstrCallerVersion, bstrAppProblem, bLaunch, &dwResult);
  103. if (TSL_SERV_FAILED(hRes))
  104. dwResult = TSL_ERROR_OBJECT_GONE;
  105. return dwResult;
  106. }
  107. DWORD LaunchDevice(ITShootATL *pITShootATL, _bstr_t &bstrCallerName,
  108. _bstr_t &bstrCallerVersion, _bstr_t &bstrPNPDeviceID,
  109. _bstr_t &bstrDeviceClassGUID, _bstr_t &bstrAppProblem, short bLaunch)
  110. {
  111. HRESULT hRes;
  112. DWORD dwResult = TSL_ERROR_GENERAL;
  113. hRes = pITShootATL->LaunchDevice(bstrCallerName, bstrCallerVersion, bstrPNPDeviceID,
  114. bstrDeviceClassGUID, bstrAppProblem, bLaunch, &dwResult);
  115. if (TSL_SERV_FAILED(hRes))
  116. dwResult = TSL_ERROR_OBJECT_GONE;
  117. return dwResult;
  118. }
  119. void SetStatusA(DWORD dwStatus, DWORD nChar, char szBuf[])
  120. {
  121. AfxLoadStringA(dwStatus, szBuf, nChar);
  122. return;
  123. }
  124. void SetStatusW(DWORD dwStatus, DWORD nChar, wchar_t szBuf[])
  125. {
  126. AfxLoadStringW(dwStatus, szBuf, nChar);
  127. return;
  128. }