Beispiel #1
0
VOID APIENTRY
CheckEscapesA(LPSTR lpFileA, DWORD cch)
{
   if (lpFileA && *lpFileA) {
      LPWSTR lpFileW;

      lpFileW = (LPWSTR)LocalAlloc(LPTR, (cch * sizeof(WCHAR)));
      if (!lpFileW) {
         return;
      }

      MultiByteToWideChar(CP_ACP, 0, lpFileA, -1 , (LPWSTR)lpFileW, cch);

      CheckEscapesW(lpFileW, cch);

      try {
         WideCharToMultiByte(CP_ACP, 0, (LPWSTR)lpFileW, -1, lpFileA, cch,
            NULL, NULL);
      } except(EXCEPTION_EXECUTE_HANDLER) {
         LocalFree(lpFileW);
         return;
      }

      LocalFree(lpFileW);
   }
Beispiel #2
0
/*************************************************************************
 * CheckEscapesA             [SHELL32.@]
 *
 * Checks a string for special characters which are not allowed in a path
 * and encloses it in quotes if that is the case.
 *
 * PARAMS
 *  string     [I/O] string to check and on return eventually quoted
 *  len        [I]   length of string
 *
 * RETURNS
 *  length of actual string
 *
 * NOTES
 *  Not really sure if this function returns actually a value at all.
 */
DWORD WINAPI CheckEscapesA(
    LPSTR	string,         /* [I/O]   string to check ??*/
    DWORD	len)            /* [I]      is 0 */
{
    LPWSTR wString;
    DWORD ret = 0;

    TRACE("(%s %d)\n", debugstr_a(string), len);
    wString = LocalAlloc(LPTR, len * sizeof(WCHAR));
    if (wString)
    {
        MultiByteToWideChar(CP_ACP, 0, string, len, wString, len);
        ret = CheckEscapesW(wString, len);
        WideCharToMultiByte(CP_ACP, 0, wString, len, string, len, NULL, NULL);
        LocalFree(wString);
    }
    return ret;
}