where is LoadLibrary A looking for the file?

后端 未结 2 438
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 15:30

My code uses LoadLibraryA(\"someDLL.dll\"); What is the path it starts searching for the file someDLL.dll?And another question : is LoadLibraryA function case-sensitive?I mean i

相关标签:
2条回答
  • 2021-01-21 15:54

    LoadlLibrary article specifies search order in Remarks:

    If lpFileName does not include a path and there is more than one loaded module with the same base name and extension, the function returns a handle to the module that was loaded first.

    If no file name extension is specified in the lpFileName parameter, the default library extension .dll is appended. However, the file name string can include a trailing point character (.) to indicate that the module name has no extension. When no path is specified, the function searches for loaded modules whose base name matches the base name of the module to be loaded. If the name matches, the load succeeds. Otherwise, the function searches for the file. [...]

    For more information on the DLL search order, see Dynamic-Link Library Search Order.

    File names are not case sensitive, so NTFS and FAT file names are. It is the fundamental rule to not assume case sensitivity:

    Naming Conventions

    The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system: [...]

    Do not assume case sensitivity.

    0 讨论(0)
  • 2021-01-21 16:18

    The MSDN Library article Dynamic-Link Library Search Order specifies the search order for desktop applications when SafeDllSearchMode is enabled, which is the default starting with Windows XP SP2:

    1. The directory from which the application loaded.
    2. The system directory. Use the GetSystemDirectory function to get the path of this directory.
    3. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
    4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
    5. The current directory.
    6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
    0 讨论(0)
提交回复
热议问题