From 6105b60ac904964f1c967b12a15e4c8719841ae7 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 31 Jan 2013 07:37:24 +0000 Subject: [PATCH] =?UTF-8?q?V=20tabeli=20ScheduledTask=20sem=20stolpec=20Wo?= =?UTF-8?q?rkingDir=20preimenoval=20v=20Directory=5F=20ter=20popravil=20me?= =?UTF-8?q?todo=20CMSITSCAOpTaskCreate::SetFromRecord(),=20da=20zdaj=20dol?= =?UTF-8?q?o=C4=8Di=20delovni=20imenik=20s=20funkcijo=20MsiGetTargetPath()?= =?UTF-8?q?.=20Tako=20mora=20zdaj=20v=20stolpcu=20Directory=5F=20pisati=20?= =?UTF-8?q?klju=C4=8D=20imenika=20(v=20tabeli=20Directory)=20in=20ne=20ve?= =?UTF-8?q?=C4=8D=20pot.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verzijo sem nastavil na 1.0.1. --- MSICALib/MSITSCA.cpp | 2 +- MSICALib/MSITSCA.h | 58 +++++++++++++++++++++++++++++++++++++++--- MSICALib/MSITSCAOp.cpp | 5 +++- MSICALib/msm/Makefile | 6 ++--- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/MSICALib/MSITSCA.cpp b/MSICALib/MSITSCA.cpp index 440d75a..3720c2d 100644 --- a/MSICALib/MSITSCA.cpp +++ b/MSICALib/MSITSCA.cpp @@ -72,7 +72,7 @@ UINT MSITSCA_API EvaluateScheduledTasks(MSIHANDLE hInstall) PMSIHANDLE hViewST; // Prepare a query to get a list/view of tasks. - uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Task,DisplayName,Application,Parameters,WorkingDir,Flags,Priority,User,Password,Author,Description,IdleMin,IdleDeadline,MaxRuntime,Condition,Component_ FROM ScheduledTask"), &hViewST); + uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Task,DisplayName,Application,Parameters,Directory_,Flags,Priority,User,Password,Author,Description,IdleMin,IdleDeadline,MaxRuntime,Condition,Component_ FROM ScheduledTask"), &hViewST); if (uiResult == ERROR_SUCCESS) { // Execute query! uiResult = ::MsiViewExecute(hViewST, NULL); diff --git a/MSICALib/MSITSCA.h b/MSICALib/MSITSCA.h index 86c72e5..50cf727 100644 --- a/MSICALib/MSITSCA.h +++ b/MSICALib/MSITSCA.h @@ -6,14 +6,14 @@ // Constants //////////////////////////////////////////////////////////////////////////// -#define MSITSCA_VERSION 0x01000000 +#define MSITSCA_VERSION 0x01000100 #define MSITSCA_VERSION_MAJ 1 #define MSITSCA_VERSION_MIN 0 -#define MSITSCA_VERSION_REV 0 +#define MSITSCA_VERSION_REV 1 -#define MSITSCA_VERSION_STR "1.0" -#define MSITSCA_VERSION_INST "1.0.0.0" +#define MSITSCA_VERSION_STR "1.0.1" +#define MSITSCA_VERSION_INST "1.0.1.0" //////////////////////////////////////////////////////////////////// @@ -293,6 +293,56 @@ inline UINT MsiRecordFormatStringW(MSIHANDLE hInstall, MSIHANDLE hRecord, unsign #endif // !UNICODE +inline UINT MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, CStringA &sValue) +{ + DWORD dwSize = 0; + UINT uiResult; + + // Query the final string length first. + uiResult = ::MsiGetTargetPathA(hInstall, szFolder, "", &dwSize); + if (uiResult == ERROR_MORE_DATA) { + // Prepare the buffer to format the string data into and read it. + LPSTR szBuffer = sValue.GetBuffer(dwSize++); + if (!szBuffer) return ERROR_OUTOFMEMORY; + uiResult = ::MsiGetTargetPathA(hInstall, szFolder, szBuffer, &dwSize); + sValue.ReleaseBuffer(uiResult == ERROR_SUCCESS ? dwSize : 0); + return uiResult; + } else if (uiResult == ERROR_SUCCESS) { + // The result is empty. + sValue.Empty(); + return ERROR_SUCCESS; + } else { + // Return error code. + return uiResult; + } +} + + +inline UINT MsiGetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, CStringW &sValue) +{ + DWORD dwSize = 0; + UINT uiResult; + + // Query the final string length first. + uiResult = ::MsiGetTargetPathW(hInstall, szFolder, L"", &dwSize); + if (uiResult == ERROR_MORE_DATA) { + // Prepare the buffer to format the string data into and read it. + LPWSTR szBuffer = sValue.GetBuffer(dwSize++); + if (!szBuffer) return ERROR_OUTOFMEMORY; + uiResult = ::MsiGetTargetPathW(hInstall, szFolder, szBuffer, &dwSize); + sValue.ReleaseBuffer(uiResult == ERROR_SUCCESS ? dwSize : 0); + return uiResult; + } else if (uiResult == ERROR_SUCCESS) { + // The result is empty. + sValue.Empty(); + return ERROR_SUCCESS; + } else { + // Return error code. + return uiResult; + } +} + + //////////////////////////////////////////////////////////////////// // Inline operators //////////////////////////////////////////////////////////////////// diff --git a/MSICALib/MSITSCAOp.cpp b/MSICALib/MSITSCAOp.cpp index 07ab39c..cddc7b9 100644 --- a/MSICALib/MSITSCAOp.cpp +++ b/MSICALib/MSITSCAOp.cpp @@ -589,6 +589,7 @@ UINT CMSITSCAOpTaskCreate::SetFromRecord(MSIHANDLE hInstall, MSIHANDLE hRecord) { UINT uiResult; int iValue; + CStringW sFolder; uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 3, m_sApplicationName); if (uiResult != ERROR_SUCCESS) return uiResult; @@ -596,7 +597,9 @@ UINT CMSITSCAOpTaskCreate::SetFromRecord(MSIHANDLE hInstall, MSIHANDLE hRecord) uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 4, m_sParameters); if (uiResult != ERROR_SUCCESS) return uiResult; - uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 5, m_sWorkingDirectory); + uiResult = ::MsiRecordGetStringW(hRecord, 5, sFolder); + if (uiResult != ERROR_SUCCESS) return uiResult; + uiResult = ::MsiGetTargetPathW(hInstall, sFolder, m_sWorkingDirectory); if (uiResult != ERROR_SUCCESS) return uiResult; if (!m_sWorkingDirectory.IsEmpty() && m_sWorkingDirectory.GetAt(m_sWorkingDirectory.GetLength() - 1) == L'\\') { // Trim trailing backslash. diff --git a/MSICALib/msm/Makefile b/MSICALib/msm/Makefile index 7cdca74..bc8f86e 100644 --- a/MSICALib/msm/Makefile +++ b/MSICALib/msm/Makefile @@ -25,7 +25,7 @@ ScheduledTask Task N Identifier Primary key, non-localized token. ScheduledTask DisplayName N Formatted Task name. ScheduledTask Application N Formatted Task application name. ScheduledTask Parameters Y Formatted Task command line parameters. -ScheduledTask WorkingDir N Formatted Task working directory. If the working directory is set to "", when the application is run, the current directory will be the directory in which the task scheduler service executable, Mstask.exe, resides. +ScheduledTask Directory_ N Directory 1 Identifier Task working directory. ScheduledTask Flags N DoubleInteger Task's flags to pass in IScheduledWorkItem::SetFlags() call. ScheduledTask Priority N DoubleInteger 32;64;128;256;16384,32768 Task's priority to pass in ITask::SetPriority() call. ScheduledTask User Y Formatted Account name to run task as. Use empty string for system account. @@ -184,8 +184,8 @@ Vse :: "$(JEZIK).$(CFG).$(PLAT).ScheduledTask-1.idt" "$(JEZIK).$(CFG).$(PLAT).ScheduledTask-1.idt" : "Makefile" "..\..\include\MSINast.mak" -if exist $@ del /f /q $@ move /y << $@ > NUL -Task DisplayName Application Parameters WorkingDir Flags Priority User Password Author Description IdleMin IdleDeadline MaxRuntime Condition Component_ -s$(MSI_TIP_ID) s255 s255 S255 s255 i4 i4 S255 S255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID) +Task DisplayName Application Parameters Directory_ Flags Priority User Password Author Description IdleMin IdleDeadline MaxRuntime Condition Component_ +s$(MSI_TIP_ID) s255 s255 S255 s$(MSI_TIP_ID) i4 i4 S255 S255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID) ScheduledTask Task <