Announcement

Collapse
No announcement yet.

Is FreeLibrary different in WinXp and Win98?

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

  • Is FreeLibrary different in WinXp and Win98?

    Hello PB-Community!

    I'm struggling with a problem concerning runtime-linking to a DLL.

    Code: FreeLibrary h_MyDll to lResult

    In WinXp lResult is > 0. So far OK.
    In Win98 I get always lResult = 0.
    I checked the %DLL_THREAD_ATTACH inside the Dll.
    It's always called correctly in both cases.

    Thanks for any help,

    Heinz Grandjean
    Heinz Grandjean
    http://www.estwgj.com/

  • #2
    Return Values
    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.
    That is, the value is immaterial.

    But it's failing on Win/98... you can get the error info by calling GetLastError
    Code:
    ...
    lResult  = FreeLibrary (h_MyDLL) 
    LE        = getLastError ()
    IF ISFALSE lResult THEN 
       Output "FreeLibrary failed with system error code " & FORMAT$(LE) 
    ...
    FormatMessage can be used to convert LE to text:
    Code:
    FUNCTION SystemErrorMessageText (BYVAL ECode AS LONG) AS STRING
      LOCAL Buffer AS ASCIIZ * 255
      FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, BYVAL %NULL, ECode, %NULL, buffer, SIZEOF(buffer), BYVAL %NULL
      FUNCTION = FORMAT$(ECode, "##### ") & Buffer
    END FUNCTION
    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      To my knowledge
      >FreeLibrary h_MyDll to lResult will always result in 0
      I could be wrong

      I took things a step farther, but less sure of it
      do
      FreeLibrary h_MyDll to h_MyDll
      Loop until h_MyDll = 0

      but its a thought
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        Thanks very much for Your help!

        Interestingly in Win98 after recieving zero for the return-value of FreeLibrary the return-value of the immediate following GetLastError is also zero.
        To sum it up, it works now relieable, but honestly I don't know exactly why
        Thanks again
        Heinz Grandjean
        Heinz Grandjean
        http://www.estwgj.com/

        Comment


        • #5
          > Freelibrary......
          >I checked the %DLL_THREAD_ATTACH inside the Dll.

          ???

          On freelibrary you should get a DLL_THREAD_DETACH as well as a DLL_PROCESS_DETACH, not "attach" notifications.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X