static PyObject *Rainmeter_RmReadDouble(RainmeterObject *self, PyObject *args) { PyObject *option; double defValue; PyArg_ParseTuple(args, "Ud", &option, &defValue); wchar_t *optionStr = PyUnicode_AsWideCharString(option, NULL); double result = RmReadDouble(self->rm, optionStr, defValue); PyMem_Free(optionStr); return PyFloat_FromDouble(result); }
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue) { MeasureData* measure = (MeasureData*)data; LPCWSTR value = RmReadString(rm, L"DestAddress", L""); if (*value) { int strLen = (int)wcslen(value) + 1; int bufLen = WideCharToMultiByte(CP_ACP, 0, value, strLen, NULL, 0, NULL, NULL); if (bufLen > 0) { char* buffer = new char[bufLen]; WideCharToMultiByte(CP_ACP, 0, value, strLen, buffer, bufLen, NULL, NULL); measure->destAddr = inet_addr(buffer); if (measure->destAddr == INADDR_NONE) { WSADATA wsaData; if (WSAStartup(0x0101, &wsaData) == 0) { LPHOSTENT pHost = gethostbyname(buffer); if (pHost) { measure->destAddr = *(DWORD*)pHost->h_addr; } else { RmLog(LOG_WARNING, L"PingPlugin.dll: Unable to get host by name"); } WSACleanup(); } else { RmLog(LOG_WARNING, L"PingPlugin.dll: Unable to start WSA"); } } delete [] buffer; } } measure->updateRate = RmReadInt(rm, L"UpdateRate", 32); measure->timeout = RmReadInt(rm, L"Timeout", 30000); measure->timeoutValue = RmReadDouble(rm, L"TimeoutValue", 30000.0); measure->finishAction = RmReadString(rm, L"FinishAction", L"", false); measure->skin = RmGetSkin(rm); }