中文路径问题?路径有中文不成功,但是如果都是英文的话就成功了《这是为什么啊?

huanglei2 huanglei2 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#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);
}
}
}
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
huanglei2
进程/线程/DLL 15,466 成员 49,169 内容