Announcement

Collapse
No announcement yet.

Full path for a DLL

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

    Full path for a DLL

    One of my clients want me to include a subroutine in my DLL which as output data
    has the full path of the DLL.(The DLL is normally not placed in the same
    directory as his application EXE file) I have seen a lot of examples of
    how to get the full path for the application file using GetModuleFileName.
    Is there a way to get the same information for a DLL?

    Krister Olsson

    #2
    Include this in your DLL (don't forget to enter the DLL name...)
    Code:
    Function ReturnPath () Export As String
      Dim ZString As Asciiz * 256
      GetModuleFileName GetModuleHandle("mydll.dll"), ZString,SizeOf (ZString)
      Function = ZString
    End Function
    ------------------
    Kind regards,
    Peter.
    Regards,
    Peter

    "Simplicity is a prerequisite for reliability"

    Comment


      #3
      Instead of allocating 256 bytes for the buffer, specify %MAX_PATH instead (%MAX_PATH = 260 bytes). ie,

      DIM Buffer AS ASCIIZ * %MAX_PATH


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

      Comment


        #4
        peter,
        that code works assuming you know the name of your dll and it hasn't been renamed by anybody (for example - if you create dlls for other programmers to use, theyd want to be able to rename it), and in some cases you may not, but we covered this in depth at http://www.powerbasic.com/support/pb...ead.php?t=3408

        best regards,
        wayne


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

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎