---
name: "PathCommonPrefixA"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.4.1-4"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/PathCommonPrefixA"
---

# PathCommonPrefixA(3w)

## NAME

**PathCommonPrefixA** (SHLWAPI.@)

## SYNOPSIS

int PathCommonPrefixA\
  (\
   LPCSTR *lpszFile1*,\
   LPCSTR *lpszFile2*,\
   LPSTR  *achPath*\
  )

## DESCRIPTION

Determine the length of the common prefix between two paths.

## PARAMS

*lpszFile1* **\[In\]**  First path for comparison.

*lpszFile2* **\[In\]**  Second path for comparison.

*achPath* **\[Out\]**  Destination for common prefix string.

## RETURNS

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.

## NOTES

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.

## IMPLEMENTATION

Declared in **"shlwapi.h"**.

Implemented in **"dlls/shlwapi/path.c"**.

Debug channel **"shell"**.
