Uploaded image for project: 'Qt Installer Framework'
  1. Qt Installer Framework
  2. QTIFW-3453

Is it possible to call a function in a DLL from a Component Script? And how?

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • General, Scripting
    • None
    • Windows

    Description

      I have successfully been able to build an Installer using QtIFW-4.8.0 on Windows and Mac (ARM64). The samples are a big help!

      It is great that there is all sorts of customizing I can do using the scripting with attaching to a package or the overall config.
      I am able to run an EXE (that is in the "data" folder) directly from the package by the following script code:

      Component.prototype.createOperations = function() { 
         try {         
             // call the base create operations function
                 component.createOperations();     
         } catch (e) {         
           console.log(e);     
         }        
           console.log("createOps start");
           // this is only set to work on Windows
           component.addOperation("Execute", "@TargetDir@/myProgram1.exe",
                                  "--root", "@TargetDir@/someSubFolder", 
                                  "arg3", "arg4");
           console.log("createOps end");
      }

      Is it also possible to similarly call a C++ function that is within a DLL directly from this QTscript (??) code?
      And if so how?
      I am only looking for this to work on Windows. (Not on Mac or Linux.)

      I am able to make a console EXE app that calls the C++ code in the DLL,
      and include that console app in the "data" folder. (But that requires an extra step on my part of wrapping. I am curious if the DLL calling can be done directly.)
      I already am adding some key words to the front of the C++ functions I want to call from my EXE console app. Are there other key words that I'd have to add to the C++ routines to make them call able?

      #include "stdafx.h"
      // ( many includes removed )
      extern "C"
      {
          __declspec(dllexport) void HelloWorld()
          {
              MessageBox(0, L"Hello World from DLL!\n", L"Hi", MB_ICONINFORMATION);
          }
      }

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            installerteam Installer Team
            roberuc Rick Oberuc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes