Announcement

Collapse
No announcement yet.

using a DLL in PBCC

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

  • Christopher Becker
    replied
    It works

    Sorry, I should have replied sooner. I got it to work with the first suggestion. I figured it was something fairly simple.

    Leave a comment:


  • Wayne Diamond
    replied
    Simple example ...

    DLL:
    Code:
    #COMPILE DLL "MYDLL.DLL"
    #INCLUDE "Win32API.inc"
    
    SUB ShowMsg ALIAS "ShowMsg" (sMsg AS STRING) EXPORT
      MSGBOX sMsg
    END SUB
    
    FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                      BYVAL fwdReason   AS LONG, _
                      BYVAL lpvReserved AS LONG) AS LONG
    FUNCTION = 1
    END FUNCTION
    EXE:
    Code:
    #COMPILE EXE
    
    DECLARE SUB ShowMsg LIB "mydll.dll" ALIAS "ShowMsg" (sMsg AS STRING)
    
    FUNCTION PBMAIN() AS LONG
     ShowMsg "Display this"
     $IF %DEF(%PB_CC32)
       STDOUT "Press a key to continue...";: WAITKEY$
     $ENDIF
    END FUNCTION
    The EXPORT statement must be used to make a sub or function available, and the ALIAS statement must be used to ensure case sensitivity - if it's not specified the function name (ShowMsg in this case) will be stored in uppercase as SHOWMSG.
    Last edited by Wayne Diamond; 25 Jul 2008, 03:01 AM.

    Leave a comment:


  • Fred Buffington
    replied
    Kevin touched on this but perhaps it should be emphasized. The function in your dll must have EXPORT before the AS clause in order to be used by another program.

    FUNCTION MYFUNCT(parameter1,parameter2...) EXPORT AS LONG/STRING,etc

    Leave a comment:


  • Kev Peel
    replied
    A simple DECLARE FUNCTION ExternalFunctionName LIB "library.dll" will enable you to call external functions as if they are part of your code. See the help file under DECLARE and the "win32api.inc" file for plenty of examples. Remember to use the "ALIAS" keyword if the function exported by the DLL is not in upper-case (PB defaults to upper-case).

    #INCLUDE only needs to be used when you have the DECLARE statements for the DLL in another source code file (a good idea if you will be distributing the DLL to others, so you can distribute the DLL and this source file).

    Leave a comment:


  • Christopher Becker
    started a topic using a DLL in PBCC

    using a DLL in PBCC

    I thought this would be simple, but I'm having no luck finding information. I have a DLL that I created in PB/Win 8 (actually, it shouldn't really matter where it came from). Can I use it in PBCC as a function?

    More generally, I'm trying to include an already-compiled (or DLL-compiled) function into my PBCC source code for the purposes of obscuring what's in the function. I want to write PBCC source code and make it available to others without them being able to see inside a particular function. I thought a DLL would be the perfect way. I've used DLLs with other apps, so I know how to set them up. But now, how to let PBCC accept them?

    Any other methods anyone can think of? The #INCLUDE directive looked promising, but alas, cannot do this.

    Thanks,
    Christopher
Working...
X