[wix-users] calling 3rd part library calls using custom action in c++

Edwin Castro egcastr at gmail.com
Tue Mar 5 08:30:57 PST 2019


Additional comments:

D) If Createnewfile exists in a separate DLL from Createfile, then
Createfile will likely fail to run after you take care of B because that
separate DLL is not included in the MSI and/or not available to be loaded
at install-time.
E) Your CustomAciton is authored to execute immediate but scheduled after
InstallFiles. First, do not attempt to change the system in immediate mode,
instead make your custom action Execute="deferred". Second, if you depend
on InstallFiles actually having made changes to the system, then you need
to run deferred anyway.

--
Edwin G. Castro


On Tue, Mar 5, 2019 at 7:40 AM Hoover, Jacob via wix-users <
wix-users at lists.wixtoolset.org> wrote:

> A)  What is CreateNewFIle, and is it able to handle the // 's?
> B)  You need something inside a fragment that you reference in your main
> authoring to "pull it in".
> C) Have you looked at your MSI post compile in Orca?  My guess is the CA
> isn't included nor scheduled due to B.
>
> -----Original Message-----
> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
> Of Hanumanthaiah, ShashikalaX via wix-users
> Sent: Tuesday, March 5, 2019 2:09 AM
> To: wix-users at lists.wixtoolset.org
> Cc: Hanumanthaiah, ShashikalaX <shashikalax.hanumanthaiah at intel.com>
> Subject: [wix-users] calling 3rd part library calls using custom action in
> c++
>
>
> Hi,
>
>     I have created a DLL which just creates a file. Iam trying call this
> Createnewfile API through custom action in wix cpp.
>     My compilation went fine but when I run the msi , The file is not
> getting created after the installation. Iam attaching the snippet for
> reference.
>    Could you please guide me where Iam going wrong .
>
>    Custionaction.cpp
> #include "Testdll.h"
>
> UINT __stdcall Createfile(
>        MSIHANDLE hInstall
>        )
> {
>        HRESULT hr = S_OK;
>        UINT er = ERROR_SUCCESS;
>
>        hr = WcaInitialize(hInstall, "Createfile");
>        ExitOnFailure(hr, "Failed to initialize");
>
>        //const char* filepath="C://shashi.txt";
>        //const char * Mode = "W";
>        //wsprintfA(filepath, "%S",L"Name");
>        //wsprintfA(Mode, "%S", L"Name");
>        //LPWSTR filepath;
>        //LPWSTR Mode;
>
> //hr = WcaGetProperty(L"Name", &filepath); //hr = WcaGetProperty(L"Mode",
> &Mode);
>        WcaLog(LOGMSG_STANDARD, "Initialized.");
>        Createnewfile("C://shashi.txt", "w");
>
>        // TODO: Add your custom action code here.
>
>
> LExit:
>        er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
>        return WcaFinalize(er);
> }
>
> product.wxs
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
>   <Product Id="*" Name="Testapp" Language="1033" Version="1.0.0.0"
> Manufacturer="Intel" UpgradeCode="37b2e1fe-dc59-41d8-9ee8-c5601dc4e1d9">
>     <Package InstallerVersion="200" Compressed="yes"
> InstallScope="perMachine" />
>
>     <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName]
> is already installed." Schedule="afterInstallFinalize"/>
>     <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" />
>    </Product>
>
>     <Fragment>
>     <Directory Id="TARGETDIR" Name="SourceDir">
>     <Directory Id="ProgramFilesFolder">
>         <Directory Id="INSTALLLOCATION" Name="Testapp" >
>           <Component Id="ProductComponent"
> Guid="19bf71c2-30e3-4e57-8dec-11889b81bab3">
>             <File Id="Testapp" Name="Testapp.exe"
> Source="..\Testapp\Debug\Testapp.exe" KeyPath="yes" />
>           </Component>
>         </Directory>
>       </Directory>
>     </Directory>
>     </Fragment>
>
>   <Fragment>
>     <Binary Id='CustomCreateBinary'
> SourceFile='..\Testappcustomaction\bin\Debug\Testappcustomaction.dll'/>
>     <CustomAction Id='CustomCreate' BinaryKey='CustomCreateBinary'
> DllEntry='Createfile' Execute='immediate'   Return='check'/>
>   </Fragment>
>
>   <Fragment>
>   <InstallUISequence>
>     <Custom Action="CustomCreate" After="InstallFiles"></Custom>
>   </InstallUISequence>
>   <InstallExecuteSequence>
>     <Custom Action="CustomCreate" After="InstallFiles"></Custom>
>   </InstallExecuteSequence>
>   </Fragment>
> </Wix>
>
>
> Thanks and Regards,
> Shashikala
>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
> NOTE: This email was received from an external source. Please use caution
> when opening links or attachments in the message.
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>



More information about the wix-users mailing list