求助!!!如何得到DLL文件中properties的信息? RT,我要在自己的代码中查看一个现有的DLL文件(路径已知)的properties的信息,应该如何获取信息? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢,楼上,问题已经解决了。代码如下:BOOL GetCurDLLInfo(CString & strCRandDes, const CString& strDLLAbbrev,const CString& strInfo){// strVersion = _T("Version: "); CString strTemp; TCHAR szFileName[MAX_PATH]; memset(szFileName, 0, sizeof(szFileName)); ::GetModuleFileName(NULL, szFileName, sizeof(szFileName)/sizeof(TCHAR)); if (!strDLLAbbrev.IsEmpty()) { strTemp = szFileName; int pos = strTemp.ReverseFind(_T('\\')); strTemp = strTemp.Left(pos); CString strFindFile; strFindFile.Format(_T("%s\\MC??O%s.dll"), strTemp, strDLLAbbrev); CFileFind finder; BOOL bWorking = finder.FindFile(strFindFile); while (bWorking) { bWorking = finder.FindNextFile(); if (!finder.IsDots()) { if (!finder.IsDirectory()) { strTemp = finder.GetFilePath(); break; } } } _tcscpy(szFileName, strTemp); } LPDWORD lpdwHandle = NULL; DWORD dwLength = ::GetFileVersionInfoSize(szFileName, lpdwHandle); if (dwLength == 0) { AfxMessageBox(_T("Get file version failed")); return FALSE; } BYTE* byteData; byteData = new BYTE[dwLength]; if (byteData == NULL) { AfxMessageBox(_T("Out of memory when get file version")); return FALSE; } memset(byteData, 0, dwLength); if (!::GetFileVersionInfo(szFileName, 0, dwLength, (LPVOID)byteData)) { AfxMessageBox(_T("Get file version failed")); delete []byteData; return FALSE; } char* pVerValue = NULL; UINT nSize = 0; VerQueryValue(byteData,TEXT("\\VarFileInfo\\Translation"), (LPVOID*)&pVerValue,&nSize); CString strSubBlock,strTranslation; strTemp.Format("000%x",*((unsigned short int *)pVerValue)); strTranslation = strTemp.Right(4); strTemp.Format("000%x",*((unsigned short int *)&pVerValue[2])); strTranslation += strTemp.Right(4); //080404b0 Chinese 040904E4 English strSubBlock.Format("\\StringFileInfo\\%s\\%s",strTranslation,strInfo); VerQueryValue(byteData,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strCRandDes.Format("%s",pVerValue); strCRandDes.TrimLeft(" "); strTemp.Format("%s",pVerValue); AfxMessageBox(strTemp); delete []byteData; return TRUE;} 请教一个问题,关于线程句柄有效性 客户端执行了closesocket(),服务端怎么知道啊,谁给实例一下 VC里面的Visual SourceSafe需要怎样进行配置?? 帮忙介绍几本关于windows操作系统原理的好书,谢谢 关于SDI切分问题! 弱问题:导入dll的API函数是什么? 请各位谈谈到底什么是“三层架构”程序设计? 本科生挑战研究生(希望大家来积极讨论) 不知道MDI的程序里子窗口的最大最小化的消息是什么 请问高手们:如何设置编译可将一个dll文件打入ocx控件 在对一个组合框操作中的问题?? 问一个编辑筐的问题。
代码如下:
BOOL GetCurDLLInfo(CString & strCRandDes, const CString& strDLLAbbrev,const CString& strInfo)
{
// strVersion = _T("Version: ");
CString strTemp;
TCHAR szFileName[MAX_PATH];
memset(szFileName, 0, sizeof(szFileName)); ::GetModuleFileName(NULL, szFileName, sizeof(szFileName)/sizeof(TCHAR));
if (!strDLLAbbrev.IsEmpty())
{
strTemp = szFileName;
int pos = strTemp.ReverseFind(_T('\\'));
strTemp = strTemp.Left(pos); CString strFindFile;
strFindFile.Format(_T("%s\\MC??O%s.dll"), strTemp, strDLLAbbrev); CFileFind finder;
BOOL bWorking = finder.FindFile(strFindFile);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (!finder.IsDots())
{
if (!finder.IsDirectory())
{
strTemp = finder.GetFilePath();
break;
}
}
} _tcscpy(szFileName, strTemp);
}
LPDWORD lpdwHandle = NULL;
DWORD dwLength = ::GetFileVersionInfoSize(szFileName, lpdwHandle);
if (dwLength == 0)
{
AfxMessageBox(_T("Get file version failed"));
return FALSE;
}
BYTE* byteData;
byteData = new BYTE[dwLength];
if (byteData == NULL)
{
AfxMessageBox(_T("Out of memory when get file version"));
return FALSE;
}
memset(byteData, 0, dwLength); if (!::GetFileVersionInfo(szFileName, 0, dwLength, (LPVOID)byteData))
{
AfxMessageBox(_T("Get file version failed"));
delete []byteData;
return FALSE;
} char* pVerValue = NULL;
UINT nSize = 0;
VerQueryValue(byteData,TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&pVerValue,&nSize); CString strSubBlock,strTranslation;
strTemp.Format("000%x",*((unsigned short int *)pVerValue));
strTranslation = strTemp.Right(4);
strTemp.Format("000%x",*((unsigned short int *)&pVerValue[2]));
strTranslation += strTemp.Right(4);
//080404b0 Chinese 040904E4 English
strSubBlock.Format("\\StringFileInfo\\%s\\%s",strTranslation,strInfo);
VerQueryValue(byteData,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize);
strSubBlock.ReleaseBuffer();
strCRandDes.Format("%s",pVerValue);
strCRandDes.TrimLeft(" ");
strTemp.Format("%s",pVerValue);
AfxMessageBox(strTemp);
delete []byteData; return TRUE;
}