C++获得版本信息如何实现

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:12:08
void CShowVersionInfoDlg::OnOK()
{

char *strFile = new char[65535];
char *lptodata = new char[65535];
void **lplpbuf = new void*;
UINT *plen = new UINT;

strFile[0] = NULL;
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));

ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = GetModuleHandle(NULL);
ofn.lpstrFilter = "PE文件\0*.dll;*.exe\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = strFile;
ofn.nMaxFile = sizeof(strFile) / sizeof(strFile[0]);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = "打开";
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstr

厉害,分配这么大空间。
char *strFile = new char[65535];
char *lptodata = new char[65535];

文件名称缓冲区也用不了那么大,顶多1k就行了,数据缓冲区,最好动态分配
在 if (decidednum != 0)
{
lpdodata = new char[ decidednum];
GetFileVersionInfoA(strFile,NULL,decidednum,lptodata);
VerQueryValueA(lptodata,"\0",lplpbuf,plen);
}

// 这样就行了