rc命令,转换rc文件为mui文件(mui资源技术)
如图展示windows项目rc文件的编译类型,rc文件使用rc命令编译为object文件,最后linker进exe
使用rc *.rc 生成res资源文件
vc使用如下方式访问资源
LoadIcon(IDI_MY_ICON);
LoadBitmap(IDI_MY_BITMAP);
LoadResource(ID_FILE)、LockResource(handle) //返回void*指向资源
跨平台的资源管理工具,地址:https://github.com/nohajc/resman
#pragma once
#include "resman.h"
// Define a global variable for each file
// It will be used to refer to the resource
constexpr resman::Resource<1> gRes1("resource_file1.jpg"); // resource with ID 1
constexpr resman::Resource<2> gRes2("resource_file2.txt"); // resource with ID 2
constexpr resman::Resource<3> gRes3("resource_file3.mp3"); // resource with ID 3
使用如下命令生成object文件
rescomp resource_list.h -o resource_bundle.o [-R resource_search_path] [-I resman_include_path]
访问资源
#include "resource_list.h"
...
resman::ResourceHandle handle{gRes1};
// ResourceHandle provides convenient interface to do things like:
// iterate over bytes
for (char c : handle) { ... }
// convert bytes to string
std::string str{handle.begin(), handle.end()};
// query size and id
unsigned size = handle.size();
unsigned id = handle.id();