0

從 char* 轉換成 LPCWSTR

 2 years ago
source link: https://fredxxx123.wordpress.com/2007/04/02/%e5%be%9e-char-%e8%bd%89%e6%8f%9b%e6%88%90-lpcwstr/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

從 char* 轉換成 LPCWSTR

發現直接用 (LPCWSTR) 強轉會失誤 囧
幸好給我找到哩tounge_smile.gif


char a[] = "aaa";
WCHAR wsz[64];
swprintf(wsz, L"%S", a);
LPCWSTR p = wsz;


void aaa(char* src)
{
        WCHAR wsrc[MAX_PATH];
        swprintf(wsrc, L"%S", src);        // 此時的 wsrc 就可當 LPCWSTR 使用哩
}


參考:
        kimklai的札記

正在載入...

發佈於 2007/04/02作者 fredxxx123分類 C++


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK