Announcement

Collapse
No announcement yet.

First call to external DLL fails?

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

  • Lance Edmonds
    replied
    It does *sound* like a timing problem, but as we have no idea what the DLL actually does when it starts up, we are only able to guess.

    When you app first starts, the DLL is loaded and it's LIBMain()/DLLMain() function is executed... it will depend on what the DLL does in this function to govern how your actual code will need to be written. For example, it could spawn a thread to perform some form of initialization, and the DLL functions may fail if executed before this initialization procedure is completed.

    Unless the DLL provides some method of providing some "status" data back from it, you'll probably not have any choice but to try using the APISLEEP() function to provide an initial delay before making your first explicit call to the DLL. Either that, or maybe just start off with a call to LEDOff before starting the real sequence of calls.

    Good luck!



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

    Leave a comment:


  • Guest's Avatar
    Guest started a topic First call to external DLL fails?

    First call to external DLL fails?

    Ok I got a really weird one - or maybe its me.

    In PB/DLL 6 I declared and external call to a dll. In a very simple WinMain I then call the function from the dll. The first time I make the call it fails, the second and third not problem. If I switch the order of the called functions always the first one fails. Below is the WinMain. If I double up on the first call it works fine. So I am thinking that the external dll does not have enough time to finish its constructor. A simple work around it to make the call twice and ignore the first call. Does anyone have any more ideas.

    Code:
    FUNCTION WINMAIN (BYVAL CurInst AS LONG, _
                      BYVAL PrvInst AS LONG, _
                      CmdLine AS ASCIIZ PTR, _
                      BYVAL CmdShow AS LONG) EXPORT AS LONG
    
      LEDFastBlink
      LEDSolid
      LEDOff
    END FUNCTION
    Thanks
Working...
X