I have got in extracting using this:
StrAlloc(&pwzFilename, MAX_PATH); ExitOnFailure(hr, "Failed to allocate temporary path"); ::GetTempPathW(MAX_PATH, pwzFilename); hr = ::StringCchCatW(pwzFilename, MAX_PATH, pwzBinary); ExitOnFailure(hr, "Failed to append filename."); hr = ::StringCchCatW(pwzFilename, MAX_PATH, L".exe"); ExitOnFailure(hr, "Failed to append filename."); hr = ExtractBinary(pwzBinary, &pbData, &cbData); ExitOnFailure(hr, "failed to extract binary data"); hFile = CreateFileW(pwzFilename, GENERIC_WRITE,FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD cbWritten = 0; if (!WriteFile(hFile, pbData, cbData, &cbWritten, NULL)) CloseHandle(hFile); But can I extract it so that it is an exe that can be run? Kind Regards, Natalie Carr Measuresoft Development Ltd., Partnership Courtyard, The Ramparts, Dundalk, Co. Louth, Ireland. Tel: +353 42 9332399 Email: natalie.c...@measuresoft.com Web: http://www.measuresoft.com -----Original Message----- From: David Connet [mailto:d...@agilityrecordbook.com] Sent: Thursday, November 22, 2012 5:36 PM To: General discussion for Windows Installer XML toolset. Subject: Re: [WiX-users] Extract Binary file from MSI C++ And make sure the phView is actually pointing at a view handle. Usually, you'd have MSIHANDLE hView; ... > If (MsiDatabaseOpenView(database, "SELECT 'Data' FROM 'Binary' WHERE > 'Name'= 'Hasp'", &hView) != ERROR_SUCCESS) ... Dave On 11/22/2012 9:19 AM, Peter Shirtcliffe wrote: > Adjust that to > > PMSIHANDLE database = MsiGetActiveDatabase(hInstall); > if (database == 0) > ; //handle the error somehow and exit > > If (MsiDatabaseOpenView(database, "SELECT 'Data' FROM 'Binary' > WHERE 'Name'= 'Hasp'", phView) != ERROR_SUCCESS) > ; // handle the error somehow and exit > > > If you're more interested in getting it done quickly then you can use > ExtractBinary from the wix wcautil/dutil libraries. Its mentioned in > these links Source > http://wix.cvs.sourceforge.net/viewvc/wix/wix/src/ca/wixca/dll/shellex > ecca.cp p?hideattic=1&revision=1.4&view=markup&pathrev=MAIN > Example > http://blogs.msdn.com/b/icumove/archive/2009/06/23/custom-action-using > -wix-re > ading-from-the-binary-table.aspx > > > -----Original Message----- > From: Natalie Carr [mailto:natalie.c...@measuresoft.com] > Sent: 22 November 2012 17:03 > To: 'General discussion for Windows Installer XML toolset.' > Subject: Re: [WiX-users] Extract Binary file from MSI C++ > > Peter, > I know now what you mean: > extern "C" UINT __stdcall InstallDrivers(MSIHANDLE hInstall) { > MsiGetActiveDatabase(hInstall); > MsiDatabaseOpenView(hInstall, "SELECT 'Data' FROM 'Binary' WHERE 'Name' > = 'Hasp'", phView); > MsiRecordReadStream(*phView, 1, szBuffer, &cbBuf); > CreateFile(szBuffer, GENERIC_WRITE,FILE_SHARE_WRITE, NULL, > CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } > > Debugging throws up no errors it just ends the setup prematurely. > Kind Regards, > > Natalie Carr > > > -----Original Message----- > From: Peter Shirtcliffe [mailto:pshirtcli...@sdl.com] > Sent: Thursday, November 22, 2012 4:54 PM > To: General discussion for Windows Installer XML toolset. > Subject: Re: [WiX-users] Extract Binary file from MSI C++ > > The argument to MsiDatabaseOpenView should be a handle to a database. > That would be there return value of MsiGetActiveDatabase. > MsiGetActiveDatabase takes and argument of an installation session > which is what the custom action is passed on entry. You've passed and > uninitialized database handle to both calls. > > -----Original Message----- > From: Natalie Carr [mailto:natalie.c...@measuresoft.com] > Sent: 22 November 2012 16:35 > To: wix-users@lists.sourceforge.net > Subject: [WiX-users] Extract Binary file from MSI C++ > > Hi I am trying to run a custom action to extract a binary file from my > WIX installer, so far I have got this but I know it is not complete > but I am not sure where I am going wrong. I am using a C++ Custom > Action and the file is an exe. Any help would greatly be appreciated. > > > > > > MsiGetActiveDatabase(hDatabase); > > MsiDatabaseOpenView(hDatabase, "SELECT 'Data' FROM 'Binary' WHERE 'Name' > = 'Hasp'", phView); > > MsiRecordReadStream(*phView, 1, szBuffer, &cbBuf); > > CreateFile(szBuffer, GENERIC_WRITE,FILE_SHARE_WRITE, NULL, > CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); > ---------------------------------------------------------------------------- -- Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users