Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to programmatically apply a transform?


2 replies to this topic

mmorris

mmorris
  • Members
  • 17 posts

Posted 26 May 2004 - 23:41

I'm having trouble getting MsiDatabaseApplyTransform to behave the way I want
and I can't seem to find any useful documentation.

Here's the code I've written. MsiDatabaseApplyTransform and MsiDatabaseCommit
both return ERROR_SUCCESS, but the msi database hasn't been changed. An
interesting piece of information is that DeleteFile returns
ERROR_SHARING_VIOLATION when I try to delete the mst file. Something is
obviously happening, but what? How can I force the transformed database to
commit?

I can get the script "WiUseXfm.vbs" to work with the same two files, but this
code doesn't work.

{
MSIHANDLE hAppInstaller;
UINT result;
transformFile = "c:\\temp\\transform.mst";

result = MsiOpenDatabase("C:\\temp\\app.msi",
MSIDBOPEN_DIRECT,
&hAppInstaller);
if (ERROR_SUCCESS != result) {
return;
}

if (MsiGetDatabaseState(hAppInstaller) != MSIDBSTATE_WRITE) {
goto err;
}

// This returns ERROR_SUCCESS for me
result = MsiDatabaseApplyTransform(hAppInstaller,
transformFile, 0);
if (ERROR_SUCCESS != result) {
goto err;
}

// This returns ERROR_SUCCESS for me
result = MsiDatabaseCommit(pData->hDatabase);
if (ERROR_SUCCESS != result) {
goto err;
}

err:
if (!DeleteFile(transformFile)) {
// GetLastError returns ERROR_SHARING_VIOLATION
DWORD err = GetLastError();
}

MsiCloseHandle(hAppInstaller);
}

Thanks in advance!
Mike
Mike Morris

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 27 May 2004 - 11:51

Are you calling this while your installation is running, or at design time?

mmorris

mmorris
  • Members
  • 17 posts

Posted 27 May 2004 - 17:45

This is happening at design time.

Mike Morris