How do I read from a version resource in Visual C++

前端 未结 7 388
情歌与酒
情歌与酒 2020-11-28 09:17

I have a version resource in my resources in a C++ project which contains version number, copyright and build details. Is there an easy way to access this at run-time to po

7条回答
  •  有刺的猬
    2020-11-28 09:58

    Something like this will give you raw access to the resource data and get you started:

    HRSRC res = ::FindResource(NULL, MAKEINTRESOURCE(MY_VERSION_ID), RT_VERSION);
    DWORD size = ::SizeofResource(NULL, res);
    HGLOBAL mem = ::LoadResource(NULL, res);
    LPVOID raw_data = ::LockResource(mem);
    ...
    ::FreeResource(mem);
    

提交回复
热议问题