Source code of Windows XP (NT5)
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.

91 lines
2.7 KiB

  1. #include "precomp.hxx"
  2. #include "message.hxx"
  3. #include "shellapi.h"
  4. // Utility function to delete an registry key and all of it's children
  5. LONG RegDeleteTree(HKEY hKey, char * lpSubKey)
  6. {
  7. HKEY hKeyNew;
  8. LONG lResult = RegOpenKeyA(hKey, lpSubKey, &hKeyNew);
  9. if (lResult != ERROR_SUCCESS)
  10. {
  11. return lResult;
  12. }
  13. char szName[256];
  14. while (ERROR_SUCCESS == RegEnumKeyA(hKeyNew, 0, szName, 256))
  15. {
  16. RegDeleteTree(hKeyNew, szName);
  17. }
  18. RegCloseKey(hKeyNew);
  19. return RegDeleteKeyA(hKey, lpSubKey);
  20. }
  21. HRESULT
  22. UpdateClassStore(
  23. IClassAdmin * pClassAdmin,
  24. char * szFilePath,
  25. char * szAuxPath, // used to specify auxillary path
  26. char * szPackageName,
  27. DWORD cchPackageName,
  28. DWORD flags,
  29. HWND hwnd )
  30. {
  31. HRESULT hr;
  32. MESSAGE Message;
  33. BOOL fAssignOrPublish = flags & 0x1;
  34. Message.fAssignOrPublish = fAssignOrPublish;
  35. Message.ActFlags = ACTFLG_RunLocally | (fAssignOrPublish==1) ? ACTFLG_Published : ACTFLG_Assigned;
  36. Message.pPackagePath = szFilePath;
  37. Message.pAuxPath = szAuxPath;
  38. Message.hwnd = hwnd;
  39. hr = DetectPackageAndRegisterIntoClassStore( &Message,
  40. szFilePath,
  41. fAssignOrPublish,
  42. pClassAdmin );
  43. szPackageName[0]=0;
  44. if (SUCCEEDED(hr))
  45. {
  46. if (Message.pPackageName)
  47. {
  48. strncpy(szPackageName, Message.pPackageName, cchPackageName);
  49. }
  50. }
  51. return hr;
  52. }
  53. HRESULT
  54. UpdateClassStoreFromIE(
  55. IClassAdmin * pClassAdmin,
  56. char * szFilePath,
  57. char * szAuxPath, // used to specify auxillary path
  58. DWORD flags,
  59. FILETIME ftStart,
  60. FILETIME ftEnd,
  61. HWND hwnd )
  62. {
  63. HRESULT hr;
  64. MESSAGE Message;
  65. BOOL fAssignOrPublish = flags & 0x1;
  66. Message.hwnd = hwnd;
  67. Message.pPackagePath = szFilePath;
  68. Message.fAssignOrPublish = fAssignOrPublish;
  69. Message.ActFlags = ACTFLG_RunLocally | (fAssignOrPublish==1) ? ACTFLG_Published : ACTFLG_Assigned;
  70. Message.pAuxPath = szAuxPath;
  71. Message.ftLow = ftStart;
  72. Message.ftHigh = ftEnd;
  73. BASE_PTYPE * pT = new CAB_FILE(szFilePath, TRUE);
  74. Message.hRoot = HKEY_CLASSES_ROOT;
  75. Message.fPathTypeKnown = 1;
  76. Message.PathType = pT->GetClassPathType(pT->GetPackageType());
  77. hr = UpdateClassStoreFromMessage( &Message, pClassAdmin );
  78. if (S_OK == hr)
  79. {
  80. pT->InstallIntoGPT( &Message,
  81. fAssignOrPublish,
  82. Message.pAuxPath );
  83. }
  84. return hr;
  85. }