Get return code from CA - "Call Function from Standard DLL" - Advanced Installer Community
Viv
Posts: 3
Joined: Sun Aug 04, 2013 10:34 pm

Get return code from CA - "Call Function from Standard DLL"

Hey,

Am trying to use Advanced Installer's Custom Action("Call Function from Standard DLL") to install CBFS.

Now the Install function requires a bunch of argument's and it works fine. Only issue seems to be in getting the return code of the function. I've tried multiple variations on the "Return Type" and also made sure the property is public(All caps name). However it seems like the return property from the function is just not getting set.

Not sure if this is of any help, but from the log file I could get this line showing the function being invoked.

MSI (s) (58:3C) [22:27:53:174]: Executing op: CustomActionSchedule(Action=CallFunctionFromDLL,ActionType=3585,Source=BinaryData,Target=CallStdFcn,CustomActionData=C:\Program Files (x86)\Someone\Something\cbfsinst.dll?D;REBOOTCHECK;C;InstallA;B;s;I;C:\Program Files (x86)\Someone\Something\cfs.cab?B;s;I;VivSomething?B;s;I;?V;B;I;true?V;D;I;2?S;I;P;RebootNeeded?)

However the return property(REBOOTCHECK) is not getting updated. It starts off as 0 and remains 0.

Weird thing is even if I make the return property "void", this function still runs fine. Not really sure how this even works or why it doesn't apply the return code to the return property.

I've seen threads like:

http://www.advancedinstaller.com/forums ... =2&t=12133
If you want to stop the installation from within your DLL function called through our "Call a function from a standard dll" predefined custom action, you can set a public property from the return value of your function. Once the property is set you can use it to condition an Error Message custom action.
All I'm trying is the first part in setting the property from the return code so that later I can add step 2 from the quote.

Any help would be appreciated.

Thank you.

PS. I'd be more than happy to attach info like the screen-shot of the custom-action / return-property / installation-log. Just not sure if it's actually of any use.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Get return code from CA - "Call Function from Standard D

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

I'm not sure why you encountered this behavior. We can only help you if you send us the .AIP (project file) to support at advancedinstaller dot com and the related DLL so we can investigate them. If it contains confidential information you can send us a small test project which reproduce this behavior.

If you have any questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Viv
Posts: 3
Joined: Sun Aug 04, 2013 10:34 pm

Re: Get return code from CA - "Call Function from Standard D

@Dan,

Thank you and cheers for your reply.

I've sent the mail to "support at advancedinstaller dot com". Hope this is just something I've missed in setting up and doesn't come down to me writing a wrapper dll to capture return code's for this third-party dll.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Get return code from CA - "Call Function from Standard D

Hello,

Please note that deferred custom actions can receive information about the installation process, mostly only embedded in the CustomActionData property. However, this type of custom actions *do not have access* to installer properties. This is the behavior of the Windows Installer.

You can take a look on the “Deferred Execution Custom Actions” article which may be useful to you.

So, whatever is the value returned by your function, it will not be set in the Windows Installer property because your “CallFunctionFromDLL” is set as “deferred”. This is the case for the “RebootNeeded” property to.

Can you please try to set your “CallFunctionsFromDLL” custom action as “Immediately” and see if the behavior still persist?

Also, it seems that your function return 0 even if your first argument is wrong.

Please let us know if that helped, otherwise give us more details.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Viv
Posts: 3
Joined: Sun Aug 04, 2013 10:34 pm

Re: Get return code from CA - "Call Function from Standard D

@Dan,

Thanks a bunch for your reply Dan. I've managed to solve it with your help. I did not know the "After the system has been successfully mofied(commit)" Execution time action was "Deferred". Thought it was just the "When the system is being modified (deferred)"

I needed a couple more tweaks with your suggestion btw,

1. Switching the CA to "Immediately" gave me a "file not found exeption". Had to move the CA to after "InstallFinalize" (Guess the source files just weren't copied before that and available for use.)
2. Reason I chose "Commit" originally was to run the CA as the LocalSystem account. Without that calling the function just bails out as it's a system driver needing Admin UAC to run fine. So now with CA running as "Immediately" and the option to run as LocalSystem disabled, I just enabled the option to run the entire installer as Admin from the "Install Parameters" and the UAC issue was sorted.


It actually works fine for me now and I can get the return code as well.
Also, it seems that your function return 0 even if your first argument is wrong.
I'd guess you're seeing that since you probably ain't running the installer as "Admin", so even if your first argument is right or wrong the function will return 0 (MS "BOOL" equalent for FALSE). If you run the installer as "Admin", then with the right first argument, the function returns 1 and with the incorrect one you'd get 0.

Thanks a bunch for your quick replies. Much appreciated.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Get return code from CA - "Call Function from Standard D

Hi,

You're welcome. I'm glad you got this working.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”