Home > Software engineering >  The great god for help C2664 HRESULT ATL: : CImage: : Save
The great god for help C2664 HRESULT ATL: : CImage: : Save

Time:10-02

Severity code shows the project file line prohibits display status
Error C2664 "HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () const 1 cannot be the parameter ": from" const char [17] "into" cost * "ConsoleApplication7 c: \ users \ user \ documents \ visual studio 2015 \ projects \ ConsoleApplication7 \ ConsoleApplication7 \ ConsoleApplication7 CPP 38


How to solve it

CodePudding user response:

HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () const
Where is a const char [17] "assigned to a cost * object?

CodePudding user response:

Fyi:
 # pragma comment (lib, "user32") 
# pragma comment (lib, "gdi32")
#include
#include
#include
#include
#include
#include
#include
Void DrawPic (HDC HDC, char * buf, int len) {
HGLOBAL hMem=GlobalAlloc (GMEM_FIXED, len);
BYTE * pMem=(BYTE *) GlobalLock (hMem);
Memcpy (pMem, buf, len);
Cost * pStream;
Retrieves the hr=CreateStreamOnHGlobal (pMem, FALSE, & amp; PStream);

CImage img.
Img. Load (pStream);
Img. The Draw (HDC, CPoint (0, 0));

Img. Destroy ();
PStream - & gt; Release ();
GlobalUnlock (hMem);
GlobalFree (hMem);
}
//HWND WINAPI GetConsoleWindow ();
Void HideTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=FALSE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Void ShowTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=TRUE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Int main () {
The HWND HWND;
HDC HDC.
HFONT HFONT;
HBITMAP HBM;
HDC hdcBits;
BITMAP bm.

System (" color F0 ");
System (" CLS ");
HideTheCursor ();
HWND=GetConsoleWindow ();
HDC=GetDC (HWND);
Hfont=CreateFont (48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Chinese regular script");
SelectObject (HDC, hfont);
TextOut (HDC, 10, 10, "this is a bubble," 8);
DeleteObject (hfont);
HBM=(HBITMAP) LoadImage (0, "C: \ \ Windows \ \ Soap Bubbles. BMP", IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
If (HBM) {
HdcBits=CreateCompatibleDC (HDC);
GetObject (HBM, sizeof (BITMAP), & amp; Bm);
SelectObject (hdcBits, HBM);
BitBlt (HDC, 200, 10, bm. BmWidth, bm. BmHeight, hdcBits, 0, 0, SRCCOPY);
DeleteDC (hdcBits);
DeleteObject (HBM);
}
getch();
The FILE * f;
F=fopen (c: \ \ "new \ \ TMP JPG", "rb");
If (f) {
Int fl=filelength (fileno (f));
Char * buf=(char *) malloc (fl);
If (buf) {
Fread (buf, fl, 1, f);
}
The fclose (f);
If (buf) {
DrawPic (HDC, buf, fl);
Free (buf);
}
}
ReleaseDC (HWND, HDC);
getch();
07 system (" color ");
System (" CLS ");
ShowTheCursor ();
return 0;
}

CodePudding user response:

reference 1st floor jianwen0529 response:
HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () const
Where is a const char [17] "assigned to a cost * object?


: yes, I want to invoke ATL CImage: : Save the first parameter is the cost, however, I want to pass a string to do

Can you put the string (string or char []) into cost? Then how to translate?

CodePudding user response:

reference monkeycfhack reply: 3/f
Quote: refer to 1st floor jianwen0529 response:

HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () const
Where is a const char [17] "assigned to a cost * object?


: yes, I want to invoke ATL CImage: : Save the first parameter is the cost, however, I want to pass a string to do

Can you put the string (string or char []) into cost? Then how to translate?


No, not the default conversion operations,
The input stream is cost? That you put the stream of data read into a string, and then handed in, but also depends on how you are actually going to specific application,

CodePudding user response:

 
Retrieves the Save (
Cost * pStream,
REFGUID guidFileType
) const throw ();
Retrieves the Save (
LPCTSTR pszFileName,
REFGUID guidFileType=GUID_NULL
) const throw ();


Can mImag. Save ((LPCTSTR) cstrings (sName));

  • Related