共用方式為


PathMakePrettyW 函式 (shlwapi.h)

將全大寫路徑轉換為所有小寫字元,讓路徑外觀一致。

語法

BOOL PathMakePrettyW(
  [in, out] LPWSTR pszPath
);

參數

[in, out] pszPath

類型: LPTSTR

長度為 null 的字串指標,MAX_PATH包含要轉換的路徑。

傳回值

類型: BOOL

如果路徑已轉換,則傳回 TRUE ,否則傳回 FALSE

備註

此函式只會在完全大寫的路徑上運作。 例如:C:\WINDOWS 將會轉換成 c:\windows,但不會變更 c:\Windows。

範例

#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main( void )
{
// Path name 1.
char buffer_1[ ] = "C:\\TEST\\FILE";
char *lpStr1;
lpStr1 = buffer_1;

// Path name 2.
char buffer_2[ ] = "c:\\test\\file";
char *lpStr2;
lpStr2 = buffer_2;

// Test path name 1.
    cout << "The content of the unconverted path is : " << lpStr1 << endl;
    cout << "The \"PathMakePretty\" function returns the value " 
         << PathMakePretty(lpStr1) << "  = TRUE & converts"  << endl;
    cout << "The content of the converted path is   : " << lpStr1 << endl;

// Test path name 2.
    cout << "\nThe content of the unconverted path is : " << lpStr2 << endl;
    cout << "The \"PathMakePretty\" function returns the value " 
         << PathMakePretty(lpStr2) << "  = FALSE & no conversion"  << endl;
    cout << "The content of the converted path is   : " << lpStr2 << endl;
}

OUTPUT:
=============
The content of the unconverted path is : C:\TEST\FILE
The "PathMakePretty" function returns the value 1  = TRUE & converts
The content of the converted path is   : C:\test\file

The content of the unconverted path is : c:\test\file
The "PathMakePretty" function returns the value 0  = FALSE & no conversion
The content of the converted path is   : c:\test\file

注意

shlwapi.h 標頭會將PathMakePretty定義為別名,根據UNICODE預處理器常數的定義,自動選取此函式的ANSI或 Unicode 版本。 混合使用編碼中性別名與非編碼中性的程序代碼,可能會導致編譯或運行時間錯誤不符。 如需詳細資訊,請參閱 函式原型的慣例

規格需求

需求
最低支援的用戶端 Windows 2000 專業版、Windows XP [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 shlwapi.h
程式庫 Shlwapi.lib
Dll Shlwapi.dll (4.71 版或更新版本)