You are close, but missing a few key aspects.
The functions that start with "Rm" (like RmReadString) get option values
from the plugin measure (from the skin .ini file). The functions that return values
to the measure are
Update for the number value of the measure, and
GetString for string value of the measure.
Here is some more information on the plugin interface.
https://docs.rainmeter.net/developers/plugin/plugin-anatomy/
https://docs.rainmeter.net/developers/plugin/cpp/
https://docs.rainmeter.net/developers/plugin/cpp/api/
So, you have all the functions defined ok, you just need to build the string correctly and return it in GetString function.
I won't go into too much of the specifics the C++ programing language since that is
beyond the scope of this support forum, but I will give you a few pointers.
First, I would set up your plugin like this:
Code: Select all
#include <Windows.h>
#include "../../API/RainmeterAPI.h"
#include <string>
struct Measure
{
std::wstring returnedString;
Measure() : returnedString(L"")
{
}
};
PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
Measure* measure = new Measure;
*data = measure;
// This example won't need to initialize anything other than
// our local measure structure.
}
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
Measure* measure = (Measure*)data;
// This example doesn't need to read any options from the measure.
}
PLUGIN_EXPORT double Update(void* data)
{
Measure* measure = (Measure*)data;
// This is the function that should do the "work" of your plugin for
// both the number value and string value of the measure.
// Make sure to build the string and save it to your measure
// structure. For example: measure->returnedString = L"...";
return 0.0;
}
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
Measure* measure = (Measure*)data;
// This function is where you return a string value back to the measure.
// Note: This function is optional and is not needed if your plugin
// only returns numbers.
return measure->returnedString.c_str();
}
PLUGIN_EXPORT void Finalize(void* data)
{
Measure* measure = (Measure*)data;
delete measure;
// This example doesn't need to do any cleanup other than
// our local measure structure.
}
Depending on your goal, you will probably want to call
GetLocalTime in your Update function. This will get the local time each time the skin is Updated (assuming that is your goal). If you goal is to just get the time once, then you might get the time in the Initialize function (or the Measure constructor like you did before).
Either way, once you get the time, you will need to "build" your string correctly and save it in your Measure structure.
You may want to read up on the standard string library, since you cannot do this:
measure->Str = std::wstring(Hours + L":" + Minutes);
Here is some good C++ references on the string library.
https://www.cplusplus.com/reference/string/wstring/
https://www.cplusplus.com/reference/string/to_wstring/
I hope that helps.
-Brian