LabWindows/CVI

Content Type
Programming Language
Current manual

GetModuleDir

GetModuleDir

int GetModuleDir (const void *moduleHandle, char directoryPathname[]);

Purpose

Obtains the name of the directory of the specified DLL module.

You can use GetModuleDir if you distribute a DLL and its related files to multiple users who might place the files in different directories. If your DLL needs to access a file that is in the same directory as the DLL, you can use GetModuleDir and MakePathname to construct the full pathname.

If the moduleHandle you specify is zero, GetModuleDir returns the same result as GetProjectDir.

Parameters

Input
Name Type Description
moduleHandle const void * Module handle of DLL.

Use the default parameter, __CVIUserHInst, to specify the handle of the module that contains the call to GetModuleDir.

You can use any valid Windows module handle.

Use 0 to indicate the project or stand-alone executable (rather than a DLL). If you pass 0 for the moduleHandle, GetModuleDir obtains the directory of the executable.
Output
Name Type Description
directoryPathname char [] The buffer in which the module directory pathname is returned.

directoryPathname must be at least MAX_PATHNAME_LEN bytes long.

Note Note  MAX_PATHNAME_LEN is only reliable for ANSI single byte strings. For UTF-8 strings, call the IsUTF8PathLengthValid function to confirm that the file path is within the operating system character limit.
GetModuleDir does not add a terminating \ to directoryPathname.

Return Value

Name Type Description
result int The result of the call.
Code Description
0 Success.
-1 Current project has no pathname; the project is untitled.
-2 There is no current project.
-3 Out of memory.
-4 Operating system is unable to determine the module directory; moduleHandle is probably invalid.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Was this information helpful?