Announcement

Collapse
No announcement yet.

Inno Setup and PB-DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Inno Setup and PB-DLL

    Hello all,

    I have a Problem with Inno-Setup, which will not or can not import my PB-DLL. My DLL is in the current Inno folder. The Setup is build correctly, but when I open the Inno window where my DLL is called, I always get a error that Inno can not import my DLL.

    Inno code declaration:

    function GetHashCode (sText: String; Code: Integer): String;
    external 'GetHashCode@files:Setup.dll stdcall setuponly';

    My DLL declaration:

    FUNCTION GetHashCode(sText AS STRING, Code AS INTEGER) EXPORT AS STRING

    Kindly regards
    Detlev

    #2
    In your PB code, use:

    Code:
     
    FUNCTION GetHashCode [B]Alias "GetHashCode"[/B] (sText AS STRING, Code AS INTEGER) EXPORT AS STRING
    Also, are you certain the parameters are BYREF (default in PB), or BYVAL? This could cause more errors.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


      #3
      Once you get the ALIAS set up you will have some other problems:

      Inno Integer = PB LONG
      Inno String = PB ASCIIZ

      Also, you *did* include setup.dll in the [FILES] section of your script, right? (use dontcopy flag).
      Ok, great guy that I am...

      Inno Script relevant code...
      Code:
      [FILES]
      "D:\utility\Serializer\CommonSourceDir\tsiupgrade.dll"; Destdir: "{tmp}"; flags:dontcopy
      ...
      CODE section  (uses same code tag as BBS and I don't know how to do that literally...
      function TsiUpgradeCheck (szTmp, szParam, szSpare: String): Integer;
      external 'TsiUpgradeCheck@files:tsiupgrade.dll';
      ... and declare vars and calling the functions.
      var
      	....
      	sTmp    : String;
      	sSpare  : String;
      	
      ResultCode :=  TsiUpgradeCheck (sTmp,'PPPS300',sSpare);   // key for PPPS 3x3x upgrade
      
      .. and PB procedure header...
      FUNCTION TsiUpgradeCheck ALIAS "TsiUpgradeCheck" _
               (szTmp AS ASCIIZ, szParam AS ASCIIZ, szSpare AS ASCIIZ) EXPORT AS LONG

      I think that should be enough to get you started...

      MCM
      Last edited by Michael Mattias; 11 Jan 2008, 01:41 PM. Reason: Added all the code
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #4
        That is very usefull. Thx Michael.

        Comment


          #5
          Hello Michael,

          thx for your sample, but it seemed that is not possible to export ASCIIZ, and I need a String in Inno, when I try the sample with DWORD, I get in Inno-Setup a access violation at address: 0012FC5E: Read of address: 0000001C

          FUNCTION GetHashCode ALIAS "GetHashCode" (sText AS ASCIIZ) EXPORT AS DWORD
          LOCAL zx AS STRING

          zx = szCode

          ' Code
          ' Code
          FUNCTION = VARPTR(zx)
          END FUNCTION
          Last edited by Detlev Schubert; 11 Jan 2008, 07:06 PM. Reason: Add text: ... I get in Inno-Setup ....

          Comment


            #6
            Perhaps it would work better if the string wasn't freed after function exit:

            Code:
            FUNCTION GetHashCode ALIAS "GetHashCode" (sText AS ASCIIZ) EXPORT AS DWORD
              [b]STATIC zx AS STRING[/b]
            
              zx = szCode 
            
              ' Code
              ' Code
              FUNCTION = [b]STRPTR(zx)[/b]
            END FUNCTION
            kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

            Comment


              #7
              Hi Kev,

              sorry but it's the same error only with another address.

              Regards
              Detlev

              Comment


                #8
                Inno Setup and PB-DLL

                Back when I cared about calling PB generated dll files from C\C++ , I was using
                the PB\DLL ver. 5 compiler.

                The following PB example worked perfectly, allowing me to export all of the
                built-in PB string functions to a stand-alone DLL, that could be called from
                C\C++.

                This approach does not work with the newer, PBWIN compilers.


                FUNCTION XUCASE$ (A AS ASCIIZ * 1) EXPORT32
                FUNCTION = UCASE$(A$)
                END FUNCTION

                Comment


                  #9
                  but it seemed that is not possible to export ASCIIZ, and I need a String in Inno
                  If you want to return a string to Inno Setup from a function in a DLL, you have to pass that string as an ASCIIZ parameter by reference and fill it in your FUNCTION code.

                  There "might" be a Pascal data type = STRING but I got this to work so I never checked further.

                  Basically I figured out how to call functions in PB-created DLLs because I am not Pascal programmer. Once I had that figured out I only needed a couple 'if' and 'select case of' in the Inno CODE section so I never bothered to learn any more.
                  Last edited by Michael Mattias; 12 Jan 2008, 08:49 AM.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                    #10
                    The following PB example worked perfectly, allowing me to export all of the
                    built-in PB string functions to a stand-alone DLL, that could be called from
                    C\C++.

                    This approach does not work with the newer, PBWIN compilers.
                    Unless I am suffering yet another 'senior moment'...

                    If your product is a programming library which exports these string functions to the user, it's probably just as well it doesn't work anymore, since this would be a license violation and we would not want to have to wait until visiting day at the jail to see you.

                    (This exact subject has come up here before). (A while ago).
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                      #11
                      Inno Setup and PB-DLL

                      Originally posted by Michael Mattias View Post
                      If your product is a programming library which exports these string functions to the user, it's probably just as well it doesn't work anymore, since this would be a license violation and we would not want to have to wait until visiting day at the jail to see you.
                      Arrest your libelous insinuations, Mr. Mattias. That DLL was never included with any product nor was it ever intended to be. It served little more than as an educational exercise, when I started learning Win32 programming.

                      BCX, not PB, has been my BASIC lingua franca for almost eight years. If you were ever inclined to examine the open source BCX translator, you might learn that I know a little something of (implementing) BASIC runtime functions, so I hardly need to peddle someone else's efforts behind a thinly veiled DLL wrapper.

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎