我用PowerBuilder编译生成的一个可执行程序,
用GetFileVersionInfoSize,GetFileVersionInfo能得到它的版本信息,
用VerQueryValue(m_lpBuffer,
TEXT("\\VarFileInfo\\Translation"),……)显示其中的语言字符集为"04091252",
用VerQueryValue(m_lpBuffer,"\\StringFileInfo\\……)时却返回0我的算法代码为: m_dwHandle = 0;
m_uiDataSize = 80;
int nRet;
m_lpData = malloc(m_uiDataSize);
// Get the version information block size,
// then use it to allocate a storage buffer.
m_dwSize = ::GetFileVersionInfoSize(m_lpszImageName, &m_dwHandle);
if(!m_dwSize)
{
AfxMessageBox("调用GetFileVersionInfoSize出错");
return ;
}
m_lpBuffer = malloc(m_dwSize);
// Get the versioninformation block
nRet=::GetFileVersionInfo(m_lpszImageName, 0, m_dwSize, m_lpBuffer);
if(!nRet)
{
AfxMessageBox("调用GetFileVersionInfo出错");
return ;
} int i;
UINT nLen;
memset(m_szLangCodePage,0,1024);
VerQueryValue(m_lpBuffer,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslate,
&nLen);
// Read the file description for each language and code page.
int nLoop;
nLoop=((nLen)/sizeof(struct LANGANDCODEPAGE));
char szTmp[2048];
for( i=0; i < nLoop; i++ )
{
wsprintf(m_szLangCodePage,
TEXT("%04x%04x"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
break;//如果有多个语言字符集,则应该继续
}//读取公司信息
CStringstrCompany;
m_lpData=NULL;
char szTmp[2048];
strcpy(szTmp,"\\StringFileInfo\\");
strcat(szTmp,m_szLangCodePage);
strcat(szTmp,"\\CompanyName");
int nRet;
nRet=::VerQueryValue(m_lpBuffer,
szTmp,
&m_lpData,
&m_uiDataSize);
if(!nRet) //此处 nRet=0 ?
return "";
strCompany.Format("%s", m_lpData);
m_lpData=NULL;
return strCompany;
;
用GetFileVersionInfoSize,GetFileVersionInfo能得到它的版本信息,
用VerQueryValue(m_lpBuffer,
TEXT("\\VarFileInfo\\Translation"),……)显示其中的语言字符集为"04091252",
用VerQueryValue(m_lpBuffer,"\\StringFileInfo\\……)时却返回0我的算法代码为: m_dwHandle = 0;
m_uiDataSize = 80;
int nRet;
m_lpData = malloc(m_uiDataSize);
// Get the version information block size,
// then use it to allocate a storage buffer.
m_dwSize = ::GetFileVersionInfoSize(m_lpszImageName, &m_dwHandle);
if(!m_dwSize)
{
AfxMessageBox("调用GetFileVersionInfoSize出错");
return ;
}
m_lpBuffer = malloc(m_dwSize);
// Get the versioninformation block
nRet=::GetFileVersionInfo(m_lpszImageName, 0, m_dwSize, m_lpBuffer);
if(!nRet)
{
AfxMessageBox("调用GetFileVersionInfo出错");
return ;
} int i;
UINT nLen;
memset(m_szLangCodePage,0,1024);
VerQueryValue(m_lpBuffer,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslate,
&nLen);
// Read the file description for each language and code page.
int nLoop;
nLoop=((nLen)/sizeof(struct LANGANDCODEPAGE));
char szTmp[2048];
for( i=0; i < nLoop; i++ )
{
wsprintf(m_szLangCodePage,
TEXT("%04x%04x"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
break;//如果有多个语言字符集,则应该继续
}//读取公司信息
CStringstrCompany;
m_lpData=NULL;
char szTmp[2048];
strcpy(szTmp,"\\StringFileInfo\\");
strcat(szTmp,m_szLangCodePage);
strcat(szTmp,"\\CompanyName");
int nRet;
nRet=::VerQueryValue(m_lpBuffer,
szTmp,
&m_lpData,
&m_uiDataSize);
if(!nRet) //此处 nRet=0 ?
return "";
strCompany.Format("%s", m_lpData);
m_lpData=NULL;
return strCompany;
;
解决方案 »
- 实时音频采集,延时会越来越大?
- 毕设紧急求助:怎样点击一个按钮打开并显示TXT已经存在的文件 在线等
- 在按钮上显示一幅位图,想把白色的位图背景去掉
- 工具栏的命令按钮使能问题
- 在对ActiveX控件添加属性的时候,遇到一个问题
- UDP 数据包发送问题。
- J2EE VS MS.net , 未来是谁的天下?请教高手
- 寻求翻转棋算法(88分)
- 怎么吧MFC改成DLL??有经验的进来知道下~~
- 各位大师,新年好!小弟有一事想求:
- MFC中调用含WCHAR字符串出错的问题.mbstowcs 和MultiByteWideChar转换时都是只转了第一个字符的问题.
- DirectShow中mp3 filter开发的一个问题
IF (li_length >= 4) THEN
// ll_strAddress contains a pointer to a string, so use the address format to resolve the
// pointer. Since the string may contain null bytes, and PowerBuilder using a null terminated
// string paradigm, we increment the char pointer to retrieve each of the four bytes in the
// language/code page sequence
lc_cp[1] = String(ll_strAddress, "address")
lc_cp[2] = String(ll_strAddress+1, "address")
lc_cp[3] = String(ll_strAddress+2, "address")
lc_cp[4] = String(ll_strAddress+3, "address")
// convert the language / codepage to a string for a subquent lookup. There are two methods
// here, one for PB-created executables and one for other third-party executables. CR 257065
// has been opened to remedy the non-standard way that PowerBuilder stores this information.
IF this.getIsPBApp() THEN //要人工设置一个参数标志为PB的exe
ls_langString = int2Hex(ASC(lc_cp[2]), 2) + int2Hex(ASC(lc_cp[1]), 2) &
+ int2Hex(Integer(int2Hex(ASC(lc_cp[4]), 2) + int2Hex(ASC(lc_cp[3]), 2)) , 4)
ELSE
ls_langString = int2Hex(ASC(lc_cp[2]), 2) + int2Hex(ASC(lc_cp[1]), 2) &
+ int2Hex(ASC(lc_cp[4]), 2) + int2Hex(ASC(lc_cp[3]), 2)
END IF
ELSE
RETURN is_null
END IF
ELSE
RETURN is_null
END IF他的算法是:
将得到的language code page 转换为对应的16进制串04091252,
再将后4位"1252"做为10进制串,再转换为16进制.
这是什么算法啊?