Announcement

Collapse
No announcement yet.

Unable to export DLL functions

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

  • Unable to export DLL functions

    Maybe I'm missing something obvious here, but no matter what I do, I am unable to compile the following code into a DLL from which the functions are exported:
    Code:
    #COMPILE DLL
    #DIM ALL
    #OPTION VERSION4
    #REGISTER NONE
    
    #INCLUDE "WIN32API.INC"
    
    FUNCTION LibMain( BYVAL hInstance AS LONG, BYVAL nReason AS LONG, BYVAL nReserved AS LONG ) EXPORT AS LONG
       SELECT CASE nReason
          CASE %DLL_PROCESS_ATTACH
             CALL Init( hInstance )
          CASE %DLL_PROCESS_DETACH
             CALL CleanUp( hInstance )
       END SELECT
       
       FUNCTION = %TRUE
    END FUNCTION
    
    SUB Init( BYVAL hInstance AS LONG )
        'Register classes
    END SUB
    
    SUB CleanUp( BYVAL hInstance AS LONG )
       'Unregister classes
    END SUB
    
    FUNCTION DoSomething( BYVAL sText AS STRING ) EXPORT AS LONG
       MSGBOX sText
    END FUNCTION
    When I compile this code and use QuickView (Windows 95) on the resulting DLL, no Export Table is listed containing the functions that should have been exported. When I attempt to use the supposedly exported functions from a different application, they cannot be located.

    Any ideas?
    If you try to make something idiot-proof, someone will invent a better idiot.

  • #2
    Hi Matthew,

    You need to use the ALIAS keyword, even if the name of the exported
    function is the same as the PB function name. So in your case
    it would be:


    FUNCTION DoSomething ALIAS "DoSomething" ( BYVAL sText AS STRING ) EXPORT AS LONG

    I have found that QuickView does not list the exported functions
    from a DLL, instead I use depends.exe (ships with Visual Studio 6).

    I've just tried out your app, and found that if you do not specify
    the ALIAS keyword, the function is exported in capitals (and I think
    it then needs to be declared in the calling app with capitals). If you
    add the ALIAS keyword, the exported function name matches in case.

    Hope this helps,

    Dorian.

    [This message has been edited by DorianDarby (edited July 03, 2000).]

    Comment


    • #3
      I should have guessed that QuickView was the problem. I've not had any trouble with it on most of the DLLs I've used it on, but I've never managed to get it to work reliably with PowerBASIC DLLs for some reason. And yes, Depends does correctly identify the two exported functions.

      Memo to PowerBASIC: it would be nice if the compiler would allow the exporting of a function with a specific ordinal number!
      If you try to make something idiot-proof, someone will invent a better idiot.

      Comment

      Working...
      X