ContentsIndex
PreviousUpNext
Resource
Topics | Functions | Structs, Records, Enums
Description

Accesses resources in VXP file, e.g. strings, image and audio data

Introduction

The resource module allows developers to retrieve resources embedded in the VXP application or other resource files. Developers may embed strings, images and audio data into VXP or resource files with the Resource Editor tool in SDK. 

Resources are identified by resource IDs, which are also generated into header file "ResID.h" by the Resource Editor tool. The string resources are loaded 

 

    #include "ResID.h"  // This file is generated by Resource Editor tool.

    // The developer must first initializes the resource first, 0 denotes English.
    vm_res_init(0);

    VMUINT32 text_buffer_length = 0;
    VMUINT32 image_buffer_length = 0;
    const VMWCHAR* text = vm_res_get_string(STR_ID_SAMPLE, &text_buffer_length);
    const void* image = vm_res_get_image(ID_IMG_SAMPLE, &image_buffer_length);

    // process the result, e.g. draw text or image.

    // Images and audios must be released with vm_res_delete after usage.
    // There is no need to call vm_res_delete() for string resources.
    vm_res_delete(ID_IMG_SAMPLE);

    // Accessing resource data pointers after calling vm_res_deinit() results in undefined behavior.
    vm_res_release();
    text = NULL;
    image = NULL;
Limitation

The resulting buffers are managed by resource modules and should not be modified.

Group
Functions
Function 
Description 
Release resources allocated by a specific resource ID after calling resource loading APIs, e.g. vm_res_get_image(), vm_res_get_audio(), and vm_res_get_binary(). 
Load and get audio data according to resource ID. The buffer is allocated by resource module and vm_res_delete() must be called when it is no longer used. 
Load and get binary data according to resource ID. The buffer is allocated by resource module and vm_res_delete() must be called when it is no longer used. 
Load and get image data according to resource ID. The buffer is allocated by resource module and vm_res_delete() must be called when it is no longer used. 
Get string by its resource ID. If there are multiple languages defined in the string table, the language passed to vm_res_init() will be used. 
Call this function prior to any other resource APIs. This function initializes the resource module, and load language-specific string data in memory. 
Release all resource and free all memory occupied. Note that any resource pointers retrieved prior to this function call become invalid. Accessing these resources after vm_res_release() results in undefined behavior. 
Structs, Records, Enums
Struct, Record, Enum 
Description 
Detailed result code for resource APIs 
Links
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.