Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Determining DLL location?

Determining DLL location?

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
5 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Justin Cooke
    wrote on last edited by
    #1

    I'm creating a couple of debugging text files from a DLL and I need these to appear only in the same directory as the DLL. I have been using GetCurrentDirectory() to determine the path and appending the filenames to that. This works fine with my test application. However, with the release application (which I have no control over), the files are created on the desktop. Is this because the application is changing the current directory? Both the application and the DLL are in the same directory (usually: c:\program files\...) So, is there a way to determine the full path to the DLL from within the DLL and not worry about the current directory? Thanks:)

    N B R J 4 Replies Last reply
    0
    • J Justin Cooke

      I'm creating a couple of debugging text files from a DLL and I need these to appear only in the same directory as the DLL. I have been using GetCurrentDirectory() to determine the path and appending the filenames to that. This works fine with my test application. However, with the release application (which I have no control over), the files are created on the desktop. Is this because the application is changing the current directory? Both the application and the DLL are in the same directory (usually: c:\program files\...) So, is there a way to determine the full path to the DLL from within the DLL and not worry about the current directory? Thanks:)

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #2

      GetModuleFileName

      1 Reply Last reply
      0
      • J Justin Cooke

        I'm creating a couple of debugging text files from a DLL and I need these to appear only in the same directory as the DLL. I have been using GetCurrentDirectory() to determine the path and appending the filenames to that. This works fine with my test application. However, with the release application (which I have no control over), the files are created on the desktop. Is this because the application is changing the current directory? Both the application and the DLL are in the same directory (usually: c:\program files\...) So, is there a way to determine the full path to the DLL from within the DLL and not worry about the current directory? Thanks:)

        B Offline
        B Offline
        Big Art
        wrote on last edited by
        #3

        Try GetModuleFileName() Art

        1 Reply Last reply
        0
        • J Justin Cooke

          I'm creating a couple of debugging text files from a DLL and I need these to appear only in the same directory as the DLL. I have been using GetCurrentDirectory() to determine the path and appending the filenames to that. This works fine with my test application. However, with the release application (which I have no control over), the files are created on the desktop. Is this because the application is changing the current directory? Both the application and the DLL are in the same directory (usually: c:\program files\...) So, is there a way to determine the full path to the DLL from within the DLL and not worry about the current directory? Thanks:)

          R Offline
          R Offline
          RobJones
          wrote on last edited by
          #4

          I use the following.. _TCHAR drive[_MAX_DRIVE]; _TCHAR dir [_MAX_DIR]; _TCHAR fname[_MAX_FNAME]; _TCHAR ext [_MAX_EXT]; _TCHAR path [_MAX_PATH]; GetModuleFileName(NULL, path, _MAX_PATH); _tsplitpath(path, drive, dir, fname, ext); CString strCurrentDir = CString(drive) + dir; Rob Whoever said nothing's impossible never tried slamming a revolving door!

          1 Reply Last reply
          0
          • J Justin Cooke

            I'm creating a couple of debugging text files from a DLL and I need these to appear only in the same directory as the DLL. I have been using GetCurrentDirectory() to determine the path and appending the filenames to that. This works fine with my test application. However, with the release application (which I have no control over), the files are created on the desktop. Is this because the application is changing the current directory? Both the application and the DLL are in the same directory (usually: c:\program files\...) So, is there a way to determine the full path to the DLL from within the DLL and not worry about the current directory? Thanks:)

            J Offline
            J Offline
            Justin Cooke
            wrote on last edited by
            #5

            Thanks for all the help. I've got things working just fine now.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups