Scroll to navigation

PathCommonPrefixA(3w) Wine API PathCommonPrefixA(3w)


PathCommonPrefixA (SHLWAPI.@)


int PathCommonPrefixA
LPCSTR lpszFile1,
LPCSTR lpszFile2,
LPSTR achPath


Determine the length of the common prefix between two paths.


lpszFile1 [In] First path for comparison.
lpszFile2 [In] Second path for comparison.
achPath [Out] Destination for common prefix string.


The length of the common prefix. This is 0 if there is no common prefix between the paths or if any parameters are invalid. If the prefix is non-zero and achPath is not NULL, achPath is filled with the common part of the prefix and NUL terminated.


A common prefix of 2 is always returned as 3. It is thus possible for the length returned to be invalid (i.e. Longer than one or both of the strings given as parameters). This Win32 behaviour has been implemented here, and cannot be changed (fixed?) without breaking other SHLWAPI calls. To work around this when using this function, always check that the byte at [common_prefix_len-1] is not a NUL. If it is, deduct 1 from the prefix.


Declared in "shlwapi.h".
Implemented in "dlls/shlwapi/path.c".
Debug channel "shell".
Oct 2012 Wine API