Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

loadlibrary woes

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

  • loadlibrary woes

    I've had to go to a loadlibrary rather than declare in one of my programs because i have 2 dlls
    with similar procedures (named the same) with same result but achieved through different means. To be specific, they are print programs 1 uses
    dllprint for preview/print the other uses xprint/graphic for preview/print.

    Im getting an error in my program compiled in pbdll6+ on the call dword line.
    Code:
      GLOBAL szLib  AS ASCIIZ * 128
      GLOBAL hLib   AS DWORD
      GLOBAL sLibname AS STRING
      GLOBAL lAddress AS DWORD
      GLOBAL lResult2 AS LONG
      GLOBAL procname AS STRING
    ...
    ...
    (in a dialog callback i have)
               CASE %ID_JOURNAL 'print journal
                 CLOSE
                 savecoid$=coid$
                 xpt$="FJP" 'from Journal Posting
                 ghInst = GetModuleHandle("wumenuw3.exe")
    
    '             IF ghInst THEN
    '             LOCAL szLib  AS ASCIIZ * 128
    '             LOCAL hLib   AS DWORD
    '             LOCAL sLibname AS STRING
    '             LOCAL lAddress AS DWORD
    '             LOCAL lResult2 AS LONG
    '             LOCAL lProcname AS STRING
    '             lProcname="printjrnl"
                 IF ghInst THEN
                   sLibname="wurptxp.dll"
                   szlib=slibname
                   hLib=loadlibrary(szlib)
                   
                   lAddress = GetProcAddress(hLib, "prntjrnl")
                   procname="prntjrnl"
                   CALL DWORD lAddress USING prntjrnl (savecoid$,xpt$,1) TO lResult2
                   FreeLibrary hLib
                 ELSE
                   sLibname="wurpt1.dll"
                   szlib=slibname
                   hLib=loadlibrary(szlib)
                   lAddress = GetProcAddress(hLib, "prntjrnl")
                   CALL DWORD lAddress USING prntjrnl (savecoid$,xpt$,1) TO lResult2
                   FreeLibrary hLib
                 END IF
    the error is
    Error 516: .... default type id(?$....) or AS required PRNTJRNL
    it points to PRNTJRNL after the USING
    I've tried using prntjrnl in quotes, defining procname as string and using procname, but the error persists. Got to be something simple im missing.
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

  • #2
    > points to PRNTJRNL after the USING

    When the USING clause of the CALL DWORD statement is used, a DECLARE statementfor the called procedure (PRNTJRNL) is required.

    Missing? Or simply not shown?
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I was using a declare when i had just the one procedure but now i have
      2 procedures called the same thing in different dlls so the declare wont work.

      So, i thought i could use loadlibrary instead.

      I originally tried
      DECLARE SUB prntjrnl LIB "WURPT1.DLL" ALIAS "PRNTJRNL" (coid$,devi$)
      DECLARE SUB prntjrnl2 LIB "WURPTXP.DLL" ALIAS "PRNTJRNL" (coid$,devi$)
      but of course that is a naming convention problem.

      Maybe i could declare it in winmain something like
      Code:
         IF ghinst THEN
            DECLARE SUB prntjrnl2 LIB "WURPTXP.DLL" ALIAS "PRNTJRNL" (coid$,devi$)
         ELSE
            DECLARE SUB prntjrnl LIB "WURPT1.DLL" ALIAS "PRNTJRNL" (coid$,devi$)
         END IF
      would that work instead ?
      No that doesnt work, cant declare inside a function/sub
      Last edited by Fred Buffington; 19 Oct 2007, 12:56 PM.
      Client Writeup for the CPA

      buffs.proboards2.com

      Links Page

      Comment


      • #4
        If you are using CALL DWORD USING you do not include the "LIB" or "ALIAS" clauses in your DECLARE.

        FWIW, PB/Win 8x supports shared aliases. If you were thinking an upgrade might do you some good... in this case it would let you use DECLARE ..LIB...ALIAS and eschew LoadLibrary/GetProcAddress/CALL DWORD entirely.

        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          ok thanks michael.
          I'll try that.

          I do have the 8.04 (and 4.04 cc).

          Im still using 6.02 though. actually using both 6 and 8.

          Oh, thanks once again for your quick response.
          Client Writeup for the CPA

          buffs.proboards2.com

          Links Page

          Comment


          • #6
            OK got it to compile.
            in declares
            Code:
               DECLARE SUB printledger (c$,d$,xxp%)
               DECLARE SUB prntjrnl (coid$,devi$)
            in callback
            Code:
                         IF ghInst THEN
                           sLibname="wurptxp.dll"
                           szlib=slibname
                           hLib=loadlibrary(szlib)
                           lAddress = GetProcAddress(hLib, "printledger")
                           xxp%=1
                           CALL DWORD lAddress USING printledger2(savecoid$,xpt$,xxp%) 
                           FreeLibrary hLib
                         ELSE
                           sLibname="wurpt1.dll"
                           szlib=slibname
                           hLib=loadlibrary(szlib)
                           lAddress = GetProcAddress(hLib, "printledger")
                           xxp%=1
                           CALL DWORD lAddress USING printledger(savecoid$,xpt$,xxp%) 
                           FreeLibrary hLib
                           'CALL printledger(savecoid$,xpt$,1)
                         END IF
            Now hopefully it works LOL

            No, get a gpf when i try to access it.

            Got it to work. Had several errors.
            My ghinst was looking for program name instead of window title. got that fixed
            lAddress was coming up 0 -- needed uppercase.
            added subs prntjrnl and printledger to program
            called them from callback
            then within prntjrnl or printledger did the call dword and other statements (instead of in callback)

            Now it calls them ok.
            Last edited by Fred Buffington; 19 Oct 2007, 03:08 PM.
            Client Writeup for the CPA

            buffs.proboards2.com

            Links Page

            Comment


            • #7
              >CALL DWORD lAddress USING printledger(savecoid$,xpt$,xxp%)

              Show DECLARE for printledger and printledger2

              Also, do you get back a non-null "laddress?" You really should test for that.
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                In declares
                Code:
                DECLARE SUB printledger (c$,d$,xxp%)
                DECLARE SUB prntjrnl (coid$,devi$)
                in Callback
                Code:
                        SELECT CASE CBCTL
                           CASE %ID_JOURNAL 'print journal
                             CLOSE
                             savecoid$=coid$
                             xpt$="FJP" 'from Journal Posting
                
                             prntjrnl savecoid$,xpt$
                .
                .
                .
                           CASE %ID_LEDGER 'print ledger
                
                             CLOSE
                             savecoid$=coid$
                             xpt$="FJP" 'from Journal Posting
                               xxp%=1
                             printledger savecoid$,xpt$,xxp% 
                .
                .
                .
                in dummy subs
                Code:
                SUB printledger (c$,d$,xxp%)
                   ghInst = findwindow(BYVAL 0,"Client Writeup Menu Version 3.10X")
                    IF ghInst THEN
                      sLibname="wurptxp.dll"
                      szlib=slibname
                      hLib=loadlibrary(szlib)
                      lAddress = GetProcAddress(hLib, "PRINTLEDGER")
                      xxp%=1
                      CALL DWORD lAddress USING printledger(c$,d$,xxp%) 'TO lResult2
                      FreeLibrary hLib
                    ELSE
                      sLibname="wurpt1.dll"
                      szlib=slibname
                      hLib=loadlibrary(szlib)
                      lAddress = GetProcAddress(hLib, "PRINTLEDGER")
                      xxp%=1
                      CALL DWORD lAddress USING printledger(c$,d$,xxp%) 'TO lResult2
                      FreeLibrary hLib
                    END IF
                END SUB
                   
                SUB prntjrnl (c$,dv$)
                   ghInst = findwindow(BYVAL 0,"Client Writeup Menu Version 3.10X")
                   IF ghInst THEN
                      sLibname="wurptxp.dll"
                      szlib=slibname
                      hLib=loadlibrary(szlib)
                      lProcname="PRNTJRNL"
                      lAddress = GetProcAddress(hLib, "PRNTJRNL")
                      lprocname="prntjrnl"
                      CALL DWORD lAddress USING prntjrnl(c$,dv$) 'TO lResult2
                      FreeLibrary hLib
                   ELSE
                      sLibname="wurpt1.dll"
                      szlib=slibname
                      hLib=loadlibrary(szlib)
                      lAddress = GetProcAddress(hLib, "PRNTJRNL")
                      xxp%=1
                      CALL DWORD lAddress USING prntjrnl(c$,dv$) 'TO lResult2
                      FreeLibrary hLib
                    END IF
                END SUB
                Client Writeup for the CPA

                buffs.proboards2.com

                Links Page

                Comment


                • #9
                  I'm glad it's working.

                  BTW...

                  >added subs prntjrnl and printledger to program

                  I'll bet it made your life a whole lot easier to put this 'call' code in little separate procedures like this instead of 'burying' the required code it in-line, didn't it?
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Sure did Michael.
                    Thanks for your help.

                    I got confused when the statement about the using part of call dword required
                    a declare statement. I was thinking "why use loadlibrary if you have to declare it anyway??? but then you explained that too.
                    Client Writeup for the CPA

                    buffs.proboards2.com

                    Links Page

                    Comment

                    Working...
                    X