diff --git a/Library/Export.cpp b/Library/Export.cpp index 870a772e..43fc0fbc 100644 --- a/Library/Export.cpp +++ b/Library/Export.cpp @@ -46,6 +46,17 @@ double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue) return parser.ReadFloat(measure->GetName(), option, defValue); } +LPCWSTR __stdcall RmReplaceVariables(void* rm, LPCWSTR str) +{ + NULLCHECK(str); + + MeasurePlugin* measure = (MeasurePlugin*)rm; + ConfigParser& parser = measure->GetMeterWindow()->GetParser(); + g_Buffer = str; + parser.ReplaceVariables(g_Buffer); + return g_Buffer.c_str(); +} + LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath) { NULLCHECK(relativePath); diff --git a/Library/Exports.def b/Library/Exports.def index 5a3edafd..6ca08df6 100644 --- a/Library/Exports.def +++ b/Library/Exports.def @@ -2,8 +2,10 @@ LIBRARY EXPORTS ; Note: If new functions are added, the Rainmeter.lib files in Plugins\API\x32 and Plugins\API\x64 ; must be replaced by the corresponding file in Library\x32\Release and Library\x64\Release. + ; Set 'true' in Rainmeter.props first to minimize the .lib size. RmReadString RmReadFormula + RmReplaceVariables RmPathToAbsolute RmExecute RmGet diff --git a/Plugins/API/RainmeterAPI.cs b/Plugins/API/RainmeterAPI.cs index d75e4a7c..a98db1df 100644 --- a/Plugins/API/RainmeterAPI.cs +++ b/Plugins/API/RainmeterAPI.cs @@ -44,6 +44,9 @@ namespace Rainmeter [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] private extern static unsafe double RmReadFormula(void* rm, char* option, double defValue); + [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] + private extern static unsafe char* RmReplaceVariables(void* rm, char* str); + [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] private extern static unsafe char* RmPathToAbsolute(void* rm, char* relativePath); @@ -87,6 +90,12 @@ namespace Rainmeter return (int)RmReadFormula((void*)m_Rm, ToUnsafe(option), defValue); } + public unsafe string ReplaceVariables(string str) + { + char* value = RmReplaceVariables((void*)m_Rm, ToUnsafe(str)); + return new string(value); + } + public unsafe string GetMeasureName() { char* value = (char*)RmGet((void*)m_Rm, 0); diff --git a/Plugins/API/RainmeterAPI.h b/Plugins/API/RainmeterAPI.h index 61b4beb7..d74d08b3 100644 --- a/Plugins/API/RainmeterAPI.h +++ b/Plugins/API/RainmeterAPI.h @@ -39,6 +39,8 @@ LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR LIBRARY_EXPORT double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue); +LIBRARY_EXPORT LPCWSTR __stdcall RmReplaceVariables(void* rm, LPCWSTR str); + LIBRARY_EXPORT LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath); LIBRARY_EXPORT void __stdcall RmExecute(void* skin, LPCWSTR command); diff --git a/Plugins/API/x32/Rainmeter.lib b/Plugins/API/x32/Rainmeter.lib index 54c30b1c..740250c6 100644 Binary files a/Plugins/API/x32/Rainmeter.lib and b/Plugins/API/x32/Rainmeter.lib differ diff --git a/Plugins/API/x64/Rainmeter.lib b/Plugins/API/x64/Rainmeter.lib index 3759b700..0fbbc7a6 100644 Binary files a/Plugins/API/x64/Rainmeter.lib and b/Plugins/API/x64/Rainmeter.lib differ