无法将参数从'PCHAR'转换为'LPCWSTR'

时间:2013-06-25 00:31:04

标签: windows api winapi

  • 我已将指针size_Drive定义为:

    PCHAR size_Drive ;
    

    然后我使用了函数lstrlen:

    size_Drive += (lstrlen(size_Drive) + 1) ;  (line 28)
    

    但它给了我以下错误:

    1>c:\users\hp.hp-pc\documents\visual studio 2008\projects\getvolumeinfo\getvolumeinfo\getvolumeinfo.cpp(28) : error C2664: 'lstrlenW' : cannot convert parameter 1 from 'PCHAR' to 'LPCWSTR'
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    

1 个答案:

答案 0 :(得分:1)

PCHARchar的typedef,而LPCWSTRconst wchar_t*的typedef,而Unicode版本lstrlen是Unicode函数的宏lstrlenW

您应该专门致电lstrlenA以使用ANSI功能。