#Features works when debugged with f5 but doesnt work when built into an executable
6 messages · Page 1 of 1 (latest)
What feature?
show code
// Function to take a screenshot and save it as JPEG (Provided Code)
void TakeScreenshot(const string& type = "") {
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
HDC hScreenDC = GetDC(NULL);
HDC hMemoryDC = CreateCompatibleDC(hScreenDC);
HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, width, height);
HGDIOBJ oldBitmap = SelectObject(hMemoryDC, hBitmap);
BitBlt(hMemoryDC, 0, 0, width, height, hScreenDC, x, y, SRCCOPY | CAPTUREBLT);
Gdiplus::Bitmap bitmap(hBitmap, NULL);
CLSID clsid;
GetEncoderClsid(L"image/jpeg", &clsid);
string timestamp = getTimestamp();
string filename = "requirements\\Screenshots\\screenshot_" + (type.empty() ? "" : type + "_") + timestamp + ".jpg";
for (char& c : filename) {
if (c == ':') c = '_';
}
wstring wFilename(filename.begin(), filename.end());
bitmap.Save(wFilename.c_str(), &clsid, NULL);
SelectObject(hMemoryDC, oldBitmap);
DeleteDC(hMemoryDC);
ReleaseDC(NULL, hScreenDC);
DeleteObject(hBitmap);
}
like its wierd cuz im sure i built the exe yesterday with the same code and it worked
even yesterday it when it worked it was by luck lol