-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiteStep.cpp
61 lines (51 loc) · 1.94 KB
/
LiteStep.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "lsapi.h"
#include <strsafe.h>
#include <shlwapi.h>
#include "LiteStep.h"
extern HWND g_hParent;
// Sets a LiteStep evar
void LiteStep::SetEvar(LPCSTR pszPrefix, LPCSTR pszEvar, LPCSTR pszFormat, ...)
{
char szNewEvar[MAX_PATH], szValue[MAX_LINE_LENGTH];
va_list argList;
// Join the Prefix with the Evar's name
StringCchCopy(szNewEvar, sizeof(szNewEvar), pszPrefix);
StringCchCat(szNewEvar, sizeof(szNewEvar), pszEvar);
// Create the Evar's value from the Format and the argList
va_start(argList, pszFormat);
StringCchVPrintfA(szValue, sizeof(szValue), pszFormat, argList);
va_end(argList);
// Without this values containing spaces will act weird
PathQuoteSpaces(szValue);
// Set the variable
LSSetVariable(szNewEvar, szValue);
}
// Reads
void LiteStep::ExecuteEvent(LPCSTR pszPrefix, LPCSTR pszEvent)
{
char szExecute[MAX_LINE_LENGTH];
LiteStep::GetPrefixedRCLine(szExecute, sizeof(szExecute), pszPrefix, pszEvent, "");
LSExecute(g_hParent, szExecute, SW_SHOWNORMAL);
}
// Gets a prefixed LiteStep Line
void LiteStep::GetPrefixedRCLine(LPSTR szDest, UINT cbBuffer, LPCSTR pszPrefix, LPCSTR pszOption, LPCSTR pszDefault)
{
char szOptionName[MAX_LINE_LENGTH];
StringCchPrintf(szOptionName, cbBuffer, "%s%s", pszPrefix, pszOption);
GetRCLine(szOptionName, szDest, cbBuffer, pszDefault);
PathUnquoteSpaces(szDest);
}
// Gets a prefixed LiteStep bool
bool LiteStep::GetPrefixedRCBool(LPCSTR pszPrefix, LPCSTR pszOption, bool bDefault)
{
char szOptionName[MAX_LINE_LENGTH];
StringCchPrintf(szOptionName, MAX_LINE_LENGTH, "%s%s", pszPrefix, pszOption);
return GetRCBoolDef(szOptionName, bDefault) != FALSE;
}
// Gets a prefixed LiteStep integer
int LiteStep::GetPrefixedRCInt(LPCSTR pszPrefix, LPCSTR pszOption, int iDefault)
{
char szOptionName[MAX_LINE_LENGTH];
StringCchPrintf(szOptionName, MAX_LINE_LENGTH, "%s%s", pszPrefix, pszOption);
return GetRCInt(szOptionName, iDefault);
}