Delo se nadaljuje. Dodana je še diagnostična verzija namestitve, ki uporablja diagnostično verzijo MSITSCA.dll za lažjo analizo. Dodal sem že prvo vrstico v tabelo ScheduledTasks, da lahko začnem razvijati MSITSCA.
Uskladil sem strukturo tabele ScheduledTask z realnimi potrebami. Estetski popravki
This commit is contained in:
parent
067a92cd89
commit
d9d01c8d13
@ -22,14 +22,15 @@ Table Column Nullable MinValue MaxValue KeyTable KeyColumn Category Set Descript
|
||||
s32 s32 s4 I4 I4 S255 I2 S32 S255 S255
|
||||
_Validation Table Column
|
||||
ScheduledTask Task N Identifier Primary key, non-localized token.
|
||||
ScheduledTask DisplayName N Formatted Task name.
|
||||
ScheduledTask Application N Formatted Task application name.
|
||||
ScheduledTask Parameters N Formatted Task command line parameters.
|
||||
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 Flags N DoubleInteger Task's flags to pass in IScheduledWorkItem::SetFlags() call.
|
||||
ScheduledTask Priority N DoubleInteger 32;64;128;256 Task's priority to pass in IScheduledWorkItem::SetPriority() call.
|
||||
ScheduledTask User N Text Account name to run task as. Use empty string for system account.
|
||||
ScheduledTask Priority N DoubleInteger 32;64;128;256 Task's priority to pass in ITask::SetPriority() call.
|
||||
ScheduledTask User Y Text Account name to run task as. Use empty string for system account.
|
||||
ScheduledTask Password Y Text Account password to run task as. Use NULL for system account.
|
||||
ScheduledTask Comment Y Text Task description.
|
||||
ScheduledTask Description Y Text Task description.
|
||||
ScheduledTask IdleMin Y Integer A value that specifies how long, in minutes, the system must remain idle before the work item can run.
|
||||
ScheduledTask IdleDeadline Y Integer A value that specifies the maximum number of minutes that the Task Scheduler will wait for the idle-time period.
|
||||
ScheduledTask MaxRuntime N DoubleInteger Specifies the maximum run time (in milliseconds), for the task. This parameter may be set to -1 to specify an unlimited time.
|
||||
@ -117,8 +118,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 Application Parameters WorkingDir Flags Priority User Password Comment IdleMin IdleDeadline MaxRuntime Condition Component_
|
||||
s$(MSI_TIP_ID) s255 s255 s255 i4 i4 s255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID)
|
||||
Task DisplayName Application Parameters WorkingDir Flags Priority User Password Description IdleMin IdleDeadline MaxRuntime Condition Component_
|
||||
s$(MSI_TIP_ID) s255 s255 S255 s255 i4 i4 S255 S255 S255 I2 I2 i4 S255 s$(MSI_TIP_ID)
|
||||
ScheduledTask Task
|
||||
<<NOKEEP
|
||||
|
||||
|
@ -42,12 +42,45 @@ UINT MSITSCA_API EvaluateScheduledTasks(MSIHANDLE hInstall)
|
||||
|
||||
UINT uiResult;
|
||||
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
|
||||
CString msg;
|
||||
CString sComponent;
|
||||
PMSIHANDLE hDatabase, hViewST;
|
||||
|
||||
msg.Format(_T("Pripni razhrošèevalnik na proces %u."), ::GetCurrentProcessId());
|
||||
::MessageBox(NULL, msg, _T("MSITSCA"), MB_OK);
|
||||
assert(0); // Attach debugger here or press "Ignore"!
|
||||
|
||||
hDatabase = ::MsiGetActiveDatabase(hInstall);
|
||||
if (!hDatabase) {
|
||||
uiResult = ERROR_INVALID_HANDLE;
|
||||
goto error1;
|
||||
}
|
||||
|
||||
uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Component_ FROM ScheduledTask"), &hViewST);
|
||||
if (uiResult != ERROR_SUCCESS) goto error1;
|
||||
|
||||
uiResult = ::MsiViewExecute(hViewST, NULL);
|
||||
if (uiResult != ERROR_SUCCESS) goto error1;
|
||||
|
||||
for (;;) {
|
||||
PMSIHANDLE hRecord;
|
||||
INSTALLSTATE iInstalled, iAction;
|
||||
|
||||
// Fetch one record from the view.
|
||||
uiResult = ::MsiViewFetch(hViewST, &hRecord);
|
||||
if (uiResult == ERROR_NO_MORE_ITEMS)
|
||||
break;
|
||||
else if (uiResult != ERROR_SUCCESS)
|
||||
goto error1;
|
||||
|
||||
uiResult = ::MsiRecordGetString(hRecord, 1, sComponent);
|
||||
if (uiResult != ERROR_SUCCESS) goto error1;
|
||||
|
||||
uiResult = ::MsiGetComponentState(hInstall, sComponent, &iInstalled, &iAction);
|
||||
if (uiResult != ERROR_SUCCESS) goto error1;
|
||||
}
|
||||
|
||||
verify(::MsiViewClose(hViewST) == ERROR_SUCCESS);
|
||||
uiResult = ERROR_SUCCESS;
|
||||
|
||||
error1:
|
||||
if (bIsCoInitialized) ::CoUninitialize();
|
||||
return uiResult;
|
||||
}
|
||||
@ -60,10 +93,8 @@ UINT MSITSCA_API InstallScheduledTasks(MSIHANDLE hInstall)
|
||||
|
||||
UINT uiResult;
|
||||
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
|
||||
CString msg;
|
||||
|
||||
msg.Format(_T("Pripni razhrošèevalnik na proces %u."), ::GetCurrentProcessId());
|
||||
::MessageBox(NULL, msg, _T("MSITSCA"), MB_OK);
|
||||
assert(0); // Attach debugger here or press "Ignore"!
|
||||
uiResult = ERROR_SUCCESS;
|
||||
|
||||
if (bIsCoInitialized) ::CoUninitialize();
|
||||
@ -78,10 +109,8 @@ UINT MSITSCA_API CommitScheduledTasks(MSIHANDLE hInstall)
|
||||
|
||||
UINT uiResult;
|
||||
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
|
||||
CString msg;
|
||||
|
||||
msg.Format(_T("Pripni razhrošèevalnik na proces %u."), ::GetCurrentProcessId());
|
||||
::MessageBox(NULL, msg, _T("MSITSCA"), MB_OK);
|
||||
assert(0); // Attach debugger here or press "Ignore"!
|
||||
uiResult = ERROR_SUCCESS;
|
||||
|
||||
if (bIsCoInitialized) ::CoUninitialize();
|
||||
@ -96,10 +125,8 @@ UINT MSITSCA_API RollbackScheduledTasks(MSIHANDLE hInstall)
|
||||
|
||||
UINT uiResult;
|
||||
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
|
||||
CString msg;
|
||||
|
||||
msg.Format(_T("Pripni razhrošèevalnik na proces %u."), ::GetCurrentProcessId());
|
||||
::MessageBox(NULL, msg, _T("MSITSCA"), MB_OK);
|
||||
assert(0); // Attach debugger here or press "Ignore"!
|
||||
uiResult = ERROR_SUCCESS;
|
||||
|
||||
if (bIsCoInitialized) ::CoUninitialize();
|
||||
|
@ -67,6 +67,48 @@ namespace MSITSCA {
|
||||
extern HINSTANCE hInstance; // roèica modula
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Lokalni include
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <msiquery.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Funkcije inline
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline UINT MsiRecordGetString(MSIHANDLE hRecord, unsigned int iField, CString &sValue)
|
||||
{
|
||||
DWORD dwSize = 0;
|
||||
UINT uiResult;
|
||||
|
||||
// Query the actual string length first.
|
||||
uiResult = ::MsiRecordGetString(hRecord, iField, _T(""), &dwSize);
|
||||
if (uiResult == ERROR_MORE_DATA) {
|
||||
// Prepare the buffer to read the string data into and read it.
|
||||
LPTSTR szBuffer = sValue.GetBuffer(dwSize++);
|
||||
uiResult = ::MsiRecordGetString(hRecord, iField, szBuffer, &dwSize);
|
||||
if (uiResult == ERROR_SUCCESS) {
|
||||
// Read succeeded.
|
||||
sValue.ReleaseBuffer(dwSize);
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
// Read failed. Empty the string and return error code.
|
||||
sValue.ReleaseBuffer(0);
|
||||
return uiResult;
|
||||
}
|
||||
} else if (uiResult == ERROR_SUCCESS) {
|
||||
// The string in database is empty.
|
||||
sValue.Empty();
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
// Return error code.
|
||||
return uiResult;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
||||
|
||||
#endif // __MSITSCA_H__
|
||||
|
@ -38,6 +38,7 @@ using namespace ATL;
|
||||
#include <assert.h>
|
||||
#include <msi.h>
|
||||
#include <msiquery.h>
|
||||
#include <mstask.h>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define verify(expr) ((void)(expr))
|
||||
|
Loading…
x
Reference in New Issue
Block a user