Announcement

Collapse
No announcement yet.

How to call this DLL??

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

  • How to call this DLL??

    I am really desperate. I bought a framegrabber that is supplied with a dll. However all the samples are in C/C++. There is some info for VB users that says:
    The DLL routines "el_XXXXX" are declared as C-functions and can not simply be used in Visual Basic programs. But there is a second set of functions "el__XXXXX" with two "__" which are declared as stdcall so they can be used in Visual Basic.

    Just declare the functions needed as follows:
    Declare Function el__OpenHW Lib "Eleye416" (Byval Hexswitch as long, Byval Mode as long) as Long

    So I wrote a simple vb program with the previous declare in a module and a small test program. The program worked. I copied the same to PB and it doesn't do as thing!! Why?

    Here is the program:

    $COMPILE EXE

    DECLARE FUNCTION el__OpenHW LIB "Eleye416" (BYVAL hexswitch AS LONG, BYVAL mode AS LONG) AS LONG

    FUNCTION PBMAIN
    DIM t&

    t& = el__OpenHW (0, 0)
    MSGBOX STR$(t&)

    END FUNCTION

    When I run this program in vb I get '-1' in the messagebox, which is correct. When I run this in pb I don't even see the messagebox. If I delete the line 't& = el__OpenHw(0,0) then I see the messagebox. Can anyone explain?

    Thanks

  • #2
    Add Alias "el__OpenHW" in Declare statement (it's compiler's jokes)
    It seems to me, that without Alias compiler converts all letters to upper register.

    [This message has been edited by Semen Matusovski (edited May 16, 2000).]

    Comment


    • #3
      Thierry,

      you might want to try a few things:
      - Try adding an ALIAS in the declaration line.
      - Try adding the full path to the DLL in the declare
      - Try adding Lib "Eleye416.DLL"

      Knuth

      ------------------
      http://www.softAware.de

      Comment


      • #4
        Thanks, it works!
        Care to explain why ;-)

        ------------------

        Comment


        • #5
          DECLARE FUNCTION el__OpenHW LIB "Eleye416" (BYVAL hexswitch AS LONG, BYVAL mode AS LONG) AS LONG
          By default, PB capitalized function names that it imports and exports unless an ALIAS clause is added to the declare statement. In Win32, exported sub/function names are case sensitive.

          Edit your function as follows:

          DECLARE FUNCTION el__OpenHW LIB "Eleye416.DLL" ALIAS "el__OpenHW" (BYVAL hexswitch AS LONG, BYVAL mode AS LONG) AS LONG

          When I run this program in vb I get '-1' in the messagebox, which is correct. When I run this in pb I don't even see the messagebox. If I delete the line 't& = el__OpenHw(0,0) then I see the messagebox. Can anyone explain?
          Sure, the answer is simple. Because your code was attempting to execute a function in an external DLL, the app was no actually able to be executed. At startup, Windows tries to resolve and link the declared function and this would have failed with a "Missing Export" error because of your function name capitalization problem.

          Why did you not see the MSGBOX result? Again, a simple explanation... you ran this code directly from within the IDE, right? If you tried to launch it via the Debugger or launch the EXE directly from Explorer, you would have seen the error message appear. When the IDE launches the application via "Compile and Run", load-time failure messages are suppressed.


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

          Comment


          • #6
            Thanks everyone, I will try to remember that about the case sensitive names and the 'alias'.


            ------------------

            Comment

            Working...
            X