Announcement

Collapse
No announcement yet.

GetDllFileName - Does this exist?

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

  • GetDllFileName - Does this exist?

    In an EXE if you want to knoe its filename you would use:

    GetModuleFileName(BYVAL 0&, TmpAsciiz, SIZEOF(TmpAsciiz))

    WinAPI says:
    The GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module.

    Is there an equivelent for a Dll?

    Petzold doesnt seem to have anything listed and the WinAPI library might do but im guessing what it would be called.

    ------------------
    Kind Regards
    Mike

  • #2
    Code:
    From MSDN
    DWORD GetModuleFileName(
      HMODULE hModule,    // handle to module
      LPTSTR lpFilename,  // file name of module
      DWORD nSize         // size of buffer
    );
    Parameters
    hModule 
    [in] Handle to the module whose file name is being requested. 
         If this parameter is NULL, GetModuleFileName returns the path for 
         the file containing the current process. 
    lpFilename 
    [out] Pointer to a buffer that receives the path and file name 
          of the specified module. 
    nSize 
    [in] Specifies the length, in TCHARs, of the lpFilename buffer. 
         If the length of the path and file name exceeds this limit, 
         the string is truncated.
    Use the DLL-Instancehandle to get the name of the DLL


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se



    [This message has been edited by Fred Oxenby (edited May 04, 2001).]
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Comment


    • #3
      Thx Fred,

      I understood:
      ... the full path and filename for the executable file ...
      to mean this function only worked for a .exe file.

      Thx again

      ------------------
      Kind Regards
      Mike

      Comment


      • #4
        Code:
        Function ReturnPath () Export As String  
          Dim lZStr As Asciiz * %MAX_PATH  
          GetModuleFileName GetModuleHandle("mydll.dll"), lZStr,SizeOf (lZStr)  
          Function = lZStr
        End Function
        ------------------
        Peter.
        mailto[email protected][email protected]</A>

        [This message has been edited by Peter Lameijn (edited May 04, 2001).]
        Regards,
        Peter

        "Simplicity is a prerequisite for reliability"

        Comment


        • #5
          Mike --

          Actually, in this context a DLL is considered to be an "executable" file. That doesn't imply that they can be executed directly, but DLLs do contain executable code.

          -- Eric

          ------------------
          Perfect Sync Development Tools
          Perfect Sync Web Site
          Contact Us: mailto:[email protected][email protected]</A>

          [This message has been edited by Eric Pearson (edited May 04, 2001).]
          "Not my circus, not my monkeys."

          Comment

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