Announcement

Collapse
No announcement yet.

Win 16: Call the Win32API Registry Functions?

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

    Win 16: Call the Win32API Registry Functions?

    I was looking for some way to get the full access to the system registry on a 32-bit system from my (16-bit) PB/DLL version 2.0 program. I searched this BBS, and found reference to something called "CALL32" which apparently allows the calling of 32-bit APIs from a 16-bit Windows program?

    But searching all the material that came with my 16-bit PB/DLL and the stuff I obtained later, and the PB FTP site, all I can find is the "Direct/32" stuff, which lets a 32-bit program call a 16-bit DLL.

    Can anyone point me at some way to call the 32-bit API from a 16-bit program? Or, point me at some resource to get me started?

    Or, tell me this is a dream and I should give up now.

    Thanks,



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

    #2
    One stupid thought: in PB/DLL-16bit Shell PB/DLL-32bit Exe module with exchanging information through external file/Clipboard

    [This message has been edited by Semen Matusovski (edited January 28, 2000).]

    Comment


      #3
      The "SHELL" is not a stupid thought. It is, however, in the opinion of one of my clients, a "kludge" which he did to get some data into a 16-bit Access(r) program. What he actually did was SHELL a 32-bit process which extracted the data from the registry and wrote it into private INI file. then he used the 16-bit "INI" file APIs to get the data into his 16-bit program.

      I was looking for a non- "client-defined-kludge" mechanism.

      The clipboard, though, there's a thought.

      The problem with the 16-bit "registration" functions is that it seems the only value you can get is the "default" value under a key, and 32-bit software tends to write data to the registry with multiple "value names" and "data values" for each key...

      Oh, where is Alan Earnshaw, author of that recent article on on registry access, when you need him?

      (I *am* going to play around with this to see if I can extract those "value name" and "value data" items from 16-bit. If I have any success, I'll post the code for a 16-bit DLL for other "legacy" programmers.)

      (Sheesh. Now Win 3.x is "legacy!" It this weren't your (USA) tax dollars at work, I'd probably say something nasty.




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

      Comment


        #4
        ok, i did some more playing around. i have reached the conclusion that, "it is not possible to use the win16 registration apis to read the win32 registration database."

        for the curious, here are references to two other situations from this bbs:



        so...

        i am going to move on. i found the call32 package; however, the documentation says you need win nt, not win32s. i have win/98, so i don't know how that's going to work out. any comments re the use of "call32" with pb/dll 16-bit will be appreciated.

        i just hope the pb compiler will let me "alias" more than one procedure to use the alias 'call32' . i seem to recall this was a restriction in pb - that is, having multiple procedure names share an alias.

        more as available...

        mcm
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


          #5
          The following code does what CALL32 does without having to use CALL32. It will work in Windows 95/98/NT, but not in 3.1 with Win32s.
          Code:
          '******************************************************************************
          '*                                                                            *
          '*  Thunk 16 to 32 for PB/DLL                                                 *
          '*  Call GetDriveTypeA 32-bit call in Win 95 or Win NT                        *
          '*  Copyright (c) 1996 by PowerBASIC, Inc.                                    *
          '*                                                                            *
          '******************************************************************************
          
          $COMPILE EXE
          $INCLUDE "WINAPI.INC"
          
          DECLARE FUNCTION LoadLibraryEx32W LIB "KERNEL" (Filename AS ASCIIZ, BYVAL hFile AS DWORD, BYVAL Flags AS DWORD) AS DWORD
          DECLARE FUNCTION FreeLibrary32W LIB "KERNEL" (BYVAL hDLL AS DWORD) AS DWORD
          DECLARE FUNCTION GetProcAddress32W LIB "KERNEL" (BYVAL hDLL AS DWORD, ProcedureName AS ASCIIZ) AS DWORD
          
          FUNCTION WinMain (BYVAL hCurInstance AS INTEGER, _
                            BYVAL hPrevInstance AS INTEGER, _
                            lpCmdLine AS ASCIIZ, _
                            BYVAL nCmdShow AS INTEGER) AS INTEGER
           
            DIM lpCaption         AS ASCIIZ * 255    ' Caption for top of message box
            DIM lpText            AS ASCIIZ * 255    ' Text of message box
            DIM n                 AS WORD
           
            DIM GetDriveTypeA     AS DWORD
            DIM CallProc32W       AS DWORD
            DIM hInstKernel       AS WORD
            DIM hInstKernel32     AS DWORD
            DIM Text              AS ASCIIZ * 255
           
            lpCaption = "Thunk Test"
           
            Text = "KERNEL"
            hInstKernel = LoadLibrary("KERNEL")
           
            CallProc32W = GetProcAddress(hinstKernel, "CALLPROC32W")
           
            FreeLibrary hinstKernel
           
            hInstKernel32 = LoadLibraryEx32W("KERNEL32", 0, 0)
           
            GetDriveTypeA = GetProcAddress32W(hInstKernel32, "GetDriveTypeA")
           
            Text = "D:\"
            CALL DWORD CallProc32W BDECL (Text, BYVAL GetDriveTypeA, BYVAL 1???, BYVAL 1???)
            ! mov n, AX
           
            FreeLibrary32W hInstKernel32
           
            lpText = STR$(n)
            MessageBox 0, lpText, lpCaption, 0
           
          END FUNCTION
          --Dave

          -------------
          PowerBASIC Support
          mailto:[email protected][email protected]</A>

          Home of the BASIC Gurus
          www.basicguru.com

          Comment


            #6
            Thanks, Dave. I will give that a shot (over the next weekend).

            My original offer holds- I get this to work, I'll post the code, except now it will include yours, too.

            MCM
            (PS: The only reason for the 'ASM mov n, AX' is to get a value to the FUNCTION?)




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

            Comment


              #7
              Michael,
              I missed this thread earlier or would have responded before now. I have
              used Call32 with great success under Win9x and NT. I decided to add any
              new functionality to my PBWinADP as 32bit DLL functions and then call them
              from the current 16bit application. Here is the psudeo code of how I
              implemented it.
              For one or two calls Dave's solution is fine but I would think it might
              produce a bit more loading and unloading of modules than Call32????

              Also by using EQUATES for the array indexes ( not shown here ) it makes the
              code quite readable.

              James


              Code:
              DECLARE _
                FUNCTION _
                  Declare32 Lib "call32" ( _
                    szFunc        AS ASCIIZ,_
                    szLibrary     AS ASCIIZ,_
                    szArgs        AS ASCIIZ _
                  ) AS LONG
              
              DECLARE _
                SUB _
                  FindUdt ( _
                          szIncFile		AS ASCIIZ, _
                          szUdtFile		AS ASCIIZ, _
                          szUdtName		AS ASCIIZ, _
                    BYVAL Id		        AS LONG _
                  )
              
              
                REDIM gCall32Ids(32) 	AS LONG
              
              
                hCall32Lib = LoadLibrary("CALL32.DLL")
              
                gCall32Address = GetProcAddress(hCall32Lib,"Call32")
              
                gCall32Ids(2) = Declare32("NewDlgMsg","adp01","p")
                gCall32Ids(3) = Declare32("AdpTest2","adp01","i")
                gCall32Ids(4) = Declare32("FindUdt","adp01","ppp")
                gCall32Ids(5) = Declare32("FindEquate","adp01","ppp")
                gCall32Ids(6) = Declare32("FindDeclare","adp01","ppp")
                gCall32Ids(7) = Declare32("NewWmCommandMsg","adp01","p")
              
                CALL DWORD gCall32Address USING FindUdt(BYCOPY sTemp, _
                                                        ModuleFilePath + "UDTS.DAT", _
                                                        szTemp,gCall32Ids(4))

              Comment


                #8
                Michael,

                Correct, the purpose of the "mov n, ax" is to get the function call result.

                --Dave


                -------------
                PowerBASIC Support
                mailto:[email protected][email protected]</A>

                Home of the BASIC Gurus
                www.basicguru.com

                Comment

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