How to add files to SUPPORTDIR
Posted 23 May 2001 - 21:29
How do I accomplish that?
Thanks
Posted 24 May 2001 - 09:21
UINT __stdcall GetAFile(MSIHANDLE hInstaller)
{
DWORD Result = ERROR_SUCCESS;
PMSIHANDLE hActiveDatabase = 0;
PMSIHANDLE hView = 0;
PMSIHANDLE hRecord;
PMSIHANDLE hInfo;
BOOL Once;
char *pBuffer = NULL;
DWORD Count = 0;
DWORD InitialCount = 0;
char FileName[INFOTIPSIZE] = "File.XXX";
DWORD FileNameLength = INFOTIPSIZE;
HANDLE hFile;
for (Once=TRUE; Once; Once=FALSE)
{
// Extract The File from the Binary Table
hActiveDatabase = MsiGetActiveDatabase(hInstaller);
if (hActiveDatabase == 0)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
Result = MsiDatabaseOpenView(hActiveDatabase,
"SELECT * FROM Binary WHERE Name='ABinary'",
&hView);
if (Result != ERROR_SUCCESS)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
Result = MsiViewExecute(hView, 0);
if (Result != ERROR_SUCCESS)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
Result = MsiViewFetch(hView, &hRecord);
if (Result != ERROR_SUCCESS)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
Count = MsiRecordDataSize(hRecord, 2);
if (Count == 0)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
// Allocate memory for file
InitialCount = Count;
pBuffer = (LPSTR)malloc (Count);
if (pBuffer==NULL)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
Result = MsiRecordReadStream(hRecord,
2,
pBuffer,
&Count);
if (Count != InitialCount)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
// Save the Extracted File
hFile = CreateFile(FileName,
GENERIC_WRITE,
0,
0,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
Result = ERROR_INSTALL_FAILURE;
break;
}
WriteFile(hFile, pBuffer, InitialCount, &Count, NULL);
CloseHandle(hFile);
Result = ERROR_SUCCESS;
} // End Once
// Cleanup
if (pBuffer) free(pBuffer);
if (hView) MsiViewClose(hView);
return Result;
}
There is a function in InstalShield script that does all this called, I believe, StreamFileFromBinary. I don't use install script so someone else will need to fill you in on that.
The CA can not be deferred because the database would be unavailable.
I do not know what SUPPORTDIR is supposed to be it does not normally exist in a windows installer context. I normally put files in the temp directory and make sure I delete them on roll back or cancelation.
Hope this helps