C2731 'WinMain': функция не может быть перегружена и C4018'<': несоответствие знака/беззнака [закрыто]C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 C2731 'WinMain': функция не может быть перегружена и C4018'<': несоответствие знака/беззнака [закрыто]

Сообщение Anonymous »

Я пытаюсь скомпилировать код в Visual Studio 2022, но получаю ошибки.
код
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int CmdShow)

Изображение

< img alt="winmain error" src="https://i.sstatic.net/DdoBuKB4.png" />
Поскольку я новичок/новичок, я попытался сделать статическая функция, которая была показана в Visual Studio. Не помогло.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

//char acUserName[100];

using namespace Gdiplus;
using namespace std;

fstream err("errormul.txt", ios::app);
fstream log_error_file("log_error.txt", ios::app);

#pragma comment(lib, "user32.lib")
#pragma comment(lib,"Wininet.lib")
#pragma comment (lib,"gdiplus.lib")

void screenshot(string file) {
ULONG_PTR gdiplustoken;
GdiplusStartupInput gdistartupinput;
GdiplusStartupOutput gdistartupoutput;

gdistartupinput.SuppressBackgroundThread = true;
GdiplusStartup(&gdiplustoken, &gdistartupinput, &gdistartupoutput); //start GDI+

HDC dc = GetDC(GetDesktopWindow());//get desktop content
HDC dc2 = CreateCompatibleDC(dc); //copy context

RECT rc0kno; // rectangle Object

GetClientRect(GetDesktopWindow(), &rc0kno);// get desktop size;
int w = rc0kno.right - rc0kno.left;//width
int h = rc0kno.bottom - rc0kno.top;//height

HBITMAP hbitmap = CreateCompatibleBitmap(dc, w, h); //create bitmap
HBITMAP holdbitmap = (HBITMAP)SelectObject(dc2, hbitmap);

BitBlt(dc2, 0, 0, w, h, dc, 0, 0, SRCCOPY); //copy pixel from pulpit to bitmap
Bitmap* bm = new Bitmap(hbitmap, NULL);

UINT num;
UINT size;

ImageCodecInfo* imagecodecinfo;
GetImageEncodersSize(&num, &size); //get count of codec

imagecodecinfo = (ImageCodecInfo*)(malloc(size));
GetImageEncoders(num, size, imagecodecinfo);//get codec

CLSID clsidEncoder;

for (int i = 0; i < num; i++)
{
if (wcscmp(imagecodecinfo.MimeType, L"image/jpeg") == 0)
clsidEncoder = imagecodecinfo.Clsid; //get jpeg codec id

}

free(imagecodecinfo);

wstring ws;
ws.assign(file.begin(), file.end()); //sring to wstring
bm->Save(ws.c_str(), &clsidEncoder); //save in jpeg format
SelectObject(dc2, holdbitmap); //Release Objects
DeleteObject(dc2);
DeleteObject(hbitmap);

ReleaseDC(GetDesktopWindow(), dc);
GdiplusShutdown(gdiplustoken);

}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int CmdShow)
{
while (true) {
SYSTEMTIME st; // create object of system time
GetLocalTime(&st);
int year = st.wYear; // extract year from system time
int month = st.wMonth; // extract month from system time
int day = st.wDay; // extract year day system time
int hour = st.wHour; // extract year hours system time
int mintue = st.wMinute; // extract mintue from system time

string yearS = to_string(year);
yearS += "_";
string monthS = to_string(month);
monthS += "-";
string dayS = to_string(day);
dayS += "-";
string hourS = to_string(hour);
hourS += "H-";
string mintueS = to_string(mintue);
mintueS += "M.jpg";

string startDate;
startDate = dayS + monthS + yearS + hourS + mintueS; // create complete string of date and time

screenshot(startDate); // send string to screenshot function
Sleep(1000 * 300 * 1); // delay execution of function 300 Seconds
}
}


Подробнее здесь: https://stackoverflow.com/questions/785 ... gned-misma
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»