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.

64 lines
1.6 KiB

  1. #include "stdinc.h"
  2. #include "macros.h"
  3. #include <msi.h>
  4. #include <msiquery.h>
  5. #include "common.h"
  6. static PWSTR s_InsertTableSQLTemporary[] =
  7. {
  8. INSERT_DIRECTORY L"TEMPORARY",
  9. INSERT_CREATEFOLDER L"TEMPORARY",
  10. INSERT_REGISTRY L"TEMPORARY",
  11. INSERT_DUPLICATEFILE L"TEMPORARY",
  12. INSERT_COMPONENT L"TEMPORARY"
  13. };
  14. HRESULT ExecuteInsertTableSQL(DWORD dwFlags, const MSIHANDLE & hdb, DWORD tableIndex, UINT cRecords, ...)
  15. {
  16. PMSIHANDLE hView = NULL;
  17. PMSIHANDLE hRecord = NULL;
  18. PCWSTR pwszRecord = NULL;
  19. va_list ap;
  20. HRESULT hr = S_OK;
  21. PWSTR pwszSQL = NULL;
  22. PARAMETER_CHECK_NTC(dwFlags == TEMPORARY_DB_OPT);
  23. pwszSQL = s_InsertTableSQLTemporary[tableIndex];
  24. hRecord = ::MsiCreateRecord(cRecords);
  25. if (hRecord == NULL)
  26. SETFAIL_AND_EXIT;
  27. //
  28. // get parameters
  29. //
  30. va_start(ap, cRecords);
  31. for (DWORD i=0; i<cRecords; i++)
  32. {
  33. pwszRecord = va_arg(ap, PCWSTR);
  34. //
  35. // set integrater
  36. //
  37. if ((tableIndex == OPT_REGISTRY) && (i == 1))
  38. {
  39. UINT x = _wtoi(pwszRecord);
  40. IF_NOTSUCCESS_SET_HRERR_EXIT(::MsiRecordSetInteger(hRecord, i+1, x));
  41. }
  42. else
  43. IF_NOTSUCCESS_SET_HRERR_EXIT(::MsiRecordSetStringW(hRecord, i+1, pwszRecord));
  44. }
  45. IF_NOTSUCCESS_SET_HRERR_EXIT(::MsiDatabaseOpenViewW(hdb, pwszSQL, &hView));
  46. IF_NOTSUCCESS_SET_HRERR_EXIT(::MsiViewExecute(hView, hRecord));
  47. Exit:
  48. va_end(ap);
  49. return hr;
  50. }