11 #include "../include/Notification.hpp" 27 showNotification(title, body);
42 char executablePath[MAX_PATH];
43 GetModuleFileName(NULL, executablePath, MAX_PATH);
46 string path(executablePath);
47 size_t lastSlash = path.find_last_of(
"\\/");
48 string directory = path.substr(0, lastSlash);
51 char fullScriptPath[MAX_PATH];
52 if (_fullpath(fullScriptPath, (directory +
"\\..\\script\\notification.ps1").c_str(), MAX_PATH)) {
53 string scriptPath(fullScriptPath);
56 char fullImagePath[MAX_PATH];
57 if (_fullpath(fullImagePath, (directory +
"\\..\\logo.png").c_str(), MAX_PATH)) {
58 string imagePath(fullImagePath);
61 string powershellCommand =
"powershell.exe -ExecutionPolicy Bypass -File \"" + scriptPath +
62 "\" -title \"" + title +
63 "\" -message \"" + body +
64 "\" -imagePath \"" + imagePath +
"\"";
68 PROCESS_INFORMATION pi;
70 ZeroMemory(&si,
sizeof(si));
72 ZeroMemory(&pi,
sizeof(pi));
75 si.dwFlags = STARTF_USESHOWWINDOW;
76 si.wShowWindow = SW_HIDE;
79 if (!CreateProcess(NULL,
80 const_cast<char*>(powershellCommand.c_str()),
90 std::cerr <<
"CreateProcess failed: " << GetLastError() << std::endl;
95 CloseHandle(pi.hProcess);
96 CloseHandle(pi.hThread);
98 cerr <<
"Failed to resolve absolute path for logo.png" << endl;
101 cerr <<
"Failed to resolve absolute path for notification.ps1" << endl;
void showNotification(const string &title, const string &body)
Displays a notification with the given title and body.
Notification(string title, string body)
Constructs a Notification object and displays the notification.