how to use cfg_var?
It's really quite simple. I see you're working from Foosion's tutorial component. He provides an cfg_var example at the top of his file (look at lines 70-78). The SDK readme and SDK/SDK/cfg_var.h also provide useful information. In your example, you seem to want to save off a string. Therefore, the cfg_var type you need is a cfg_string. The first step is to generate a GUID (using guidgen.exe):
// {00000000-0000-0000-0000-000000000000}
// USE THE GUID created from GUIDGEN, not this one.
static const GUID <<name>> =
{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
Give your GUID a name (replace the <<name>> portion of it):
// {00000000-0000-0000-0000-000000000000}
static const GUID guid_cfg_TempChar = { ... /* as before */ };
Now declare a static global variable of type cfg_string:
static cfg_string cfg_TempChar(...);
What do we put inside the brackets (where those ...s are)? The first parameter is a guid (this is the going to be the key that foobar2000 will put in the cfg). We can use the GUID we created earlier:
static cfg_string cfg_test_dir(guid_cfg_TempChar, ...);
The second parameter is the default value for the cfg (This will be the value of the cfg_ if it doesn't exist in cfg yet). Put in the default that you want the parameter to take:
static cfg_string cfg_test_dir(guid_cfg_TempChar, "V:\\");
This should leave your final code looking something like this:
// This was the GUID that GUIDGen spat for me when I ran it
// just now. It's going to be different with yours
static const GUID guid_cfg_TempChar =
{ 0x2fb8448f, 0xa689, 0x4d35, { 0xb9, 0x6, 0x4b, 0x44, 0x4, 0x73, 0x94, 0xcc } };
static cfg_string cfg_test_dir(guid_cfg_TempChar, "V:\\");
If you want to set the value do this:
cfg_test_dir = "Whatever";
If you want to retrieve the value you can do this:
const char *ExeDir = cfg_test_dir
And Foobar2000 will take care of the rest. For non-string datatypes, you have cfg_int, cfg_bool, even a generic cfg_struct<>.