I've seen the following code that takes a screenshot and saves it as jpg, I've managed to compile and run it as win32 CONSOLE application,
But when I tried to use the following code in A windowsForm/CLI (there is just a button that should take a screenshot) project, I got the following errors:
1>screenshoter.obj : warning LNK4248: unresolved typeref token (0100002C) for 'Gdiplus.GpCachedBitmap'; image may not run
1>screenshoter.obj : error LNK2028: unresolved token (0A000017) "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC@@$$J18YGHPAUHWND__@@PAUHDC__@@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A000018) "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A000019) "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt@@$$J236YGHPAUHDC__@@HHHH0HHK@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001A) "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001B) "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap@@$$J212YGPAUHBITMAP__@@PAUHDC__@@HH@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001C) "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC@@$$J14YGPAUHDC__@@PAU1@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001D) "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001E) "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC@@$$J18YGHPAUHWND__@@PAUHDC__@@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt@@$$J236YGHPAUHDC__@@HHHH0HHK@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap@@$$J212YGPAUHBITMAP__@@PAUHDC__@@HH@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC@@$$J14YGPAUHDC__@@PAU1@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen@Form1@screenshoter@@$$FA$AAMXXZ)
Note: That I've included all the files needed
I looked up in MSDN, but I couldn't really understand the error messeges. Moreover, I had encountered similar messages in the past, i solved it but adding a .lib file
This time I tried adding, however it didn't solve the problem
#pragma comment( lib, "GdiPlus.lib" )