中文路径问题?路径有中文不成功,但是如果都是英文的话就成功了《这是为什么啊?
#include<stdio.h>
#include<Windows.h>
#include<Winbase.h>
#pragma comment(lib,"version.lib")
void getfileinfo(WCHAR* Msg);
void main()
{ WCHAR a[]=L"E:\\迅雷\\Program\\DoctorService";
getfileinfo(a);
getmodiftime(a);
}
void getfileinfo(WCHAR* Msg)
//转化wchar 位char
{
//获取文件信息
DWORD ll;
DWORD fileinfolong=GetFileVersionInfoSize(Msg,&ll);
LPVOID pBuf=malloc(fileinfolong);
if(GetFileVersionInfo(Msg,0,fileinfolong,pBuf))
{ WCHAR SubBlock[255]=L""; DWORD i=0;TCHAR* lpBuffer;
UINT dwBytes=0;
struct LANGANDCODEPAGE{
WORD wLanguage;
WORD wCodePage;
}*lpTranslate;
// Read the list of languages and code pages.
DWORD cbTranslate = 0;
VerQueryValue(pBuf,TEXT("\\VarFileInfo\\Translation"),(LPVOID*)&lpTranslate,(PUINT)&cbTranslate);
// Read the file description for each language and code page.
for(i=0;i<(cbTranslate/sizeof(struct LANGANDCODEPAGE));i++ )
{ wsprintf(SubBlock,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
// Retrieve file description for language and code page "i".
VerQueryValue(pBuf,SubBlock,(LPVOID*)&lpBuffer,&dwBytes);
//打印出文件公司
printf("文件描述%ws\n",lpBuffer);
}
}
}