{"id":1739,"date":"2018-09-25T18:47:50","date_gmt":"2018-09-25T10:47:50","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=1739"},"modified":"2018-10-25T16:13:25","modified_gmt":"2018-10-25T08:13:25","slug":"mfc-c-%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e5%b7%a5%e7%a8%8b%e8%b5%84%e6%ba%90%e8%a7%86%e5%9b%be%e4%b8%adversion%e6%96%87%e4%bb%b6%e4%b8%ad%e7%9a%84%e8%bd%af%e4%bb%b6%e7%89%88%e6%9c%ac%e5%8f%b7","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/1739","title":{"rendered":"mfc c++ \u5982\u4f55\u83b7\u53d6\u5de5\u7a0b\u8d44\u6e90\u89c6\u56fe\u4e2dVersion\u6587\u4ef6\u4e2d\u7684\u8f6f\u4ef6\u7248\u672c\u53f7"},"content":{"rendered":"

\u9996\u5148\u5de5\u7a0b\u9700\u8981\u5f15\u7528 Version.lib\uff0c\u8fd9\u4e2a\u5e93\u3002
\n\u9879\u76ee\u300b\u5c5e\u6027\u9875\u300b\u914d\u7f6e\u5c5e\u6027\u300b\u94fe\u63a5\u5668\u300b\u8f93\u5165\u300b\u9644\u52a0\u4f9d\u8d56\u9879
\ndebug\u548crelease\u90fd\u8981\u6dfb\u52a0\u3002<\/p>\n

CString GetSoftwareVersion()\r\n{\r\n\r\n\tTCHAR szFullPath[MAX_PATH];\r\n\tDWORD dwVerInfoSize = 0;\r\n\tDWORD dwVerHnd;\r\n\tVS_FIXEDFILEINFO * pFileInfo;\r\n\r\n\t::GetModuleFileName(NULL, szFullPath, sizeof(szFullPath));\r\n\tdwVerInfoSize = ::GetFileVersionInfoSize(szFullPath, &dwVerHnd);\r\n\tif (dwVerInfoSize)\r\n\t{\r\n\t\t\/\/ If we were able to get the information, process it:\r\n\t\tHANDLE  hMem;\r\n\t\tLPVOID  lpvMem;\r\n\t\tunsigned int uInfoSize = 0;\r\n\r\n\t\thMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);\r\n\t\tlpvMem = GlobalLock(hMem);\r\n\t\tGetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);\r\n\r\n\t\t::VerQueryValue(lpvMem, (LPTSTR)_T(\"\\\\\"), (void**)&pFileInfo, &uInfoSize);\r\n\r\n\t\tWORD m_nProdVersion[4];\r\n\r\n\t\t\/\/ Product version from the FILEVERSION of the version info resource \r\n\t\tm_nProdVersion[0] = HIWORD(pFileInfo->dwProductVersionMS); \r\n\t\tm_nProdVersion[1] = LOWORD(pFileInfo->dwProductVersionMS);\r\n\t\tm_nProdVersion[2] = HIWORD(pFileInfo->dwProductVersionLS);\r\n\t\tm_nProdVersion[3] = LOWORD(pFileInfo->dwProductVersionLS); \r\n\r\n\t\tCString strVersion ;\r\n\t\t\/\/strVersion.Format(_T(\"The file's version : %d.%d.%d.%d\"),m_nProdVersion[0],m_nProdVersion[1],m_nProdVersion[2],m_nProdVersion[3]);\r\n\t\tstrVersion.Format(_T(\"%d.%d.%d.%d\"),m_nProdVersion[0],m_nProdVersion[1],m_nProdVersion[2],m_nProdVersion[3]);\r\n\r\n\t\tGlobalUnlock(hMem);\r\n\t\tGlobalFree(hMem);\r\n\r\n\t\treturn strVersion;\r\n\t\t\/\/AfxMessageBox(strVersion);\r\n\t}\r\n\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u9996\u5148\u5de5\u7a0b\u9700\u8981\u5f15\u7528 Version.lib\uff0c\u8fd9\u4e2a\u5e93\u3002 \u9879\u76ee\u300b\u5c5e\u6027\u9875\u300b\u914d\u7f6e\u5c5e\u6027\u300b\u94fe\u63a5\u5668\u300b\u8f93\u5165\u300b\u9644\u52a0\u4f9d\u8d56\u9879 debug\u548crelease\u90fd\u8981\u6dfb\u52a0\u3002 CString GetSoftwareVersion() { TCHAR szFullPath[MAX_PATH]; DWORD dwVerInfoSize = 0; DWORD dwVerHnd; VS_FIXEDFILEINFO * pFileInfo; ::GetModuleFileName(NULL, szFullPath, sizeof(szFullPath)); dwVerInfoSize = ::GetFileVersionInfoSize(<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,219,9],"tags":[289,290],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1739"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=1739"}],"version-history":[{"count":2,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1739\/revisions"}],"predecessor-version":[{"id":1760,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1739\/revisions\/1760"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=1739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=1739"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=1739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}