Hi All,
I am trying to save the clipboard content as a bmp file. I tried like this:
Code:
HANDLE hBmp;
OpenClipboard();
hBmp = GetClipboardData(CF_DIB);
if(hBmp)
{
if (WriteDIB("c:\\TEST.BMP",GetClipboardData(CF_DIB)) == TRUE)
{
MessageBox("Success","BMP Written",NULL);
}
else
{
MessageBox("Failed","BMP Write",NULL);
}
EmptyClipboard ();
}
else
{
printerror(GetLastError());
}
CloseClipboard();
void printerror(long err)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,NULL,err,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR)&lpMsgBuf,30,NULL);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
}
I am getting NULL in hBmp. So if condition fails. I tried to get the error code. But error message says "Function completed successfully". Can anyone help me where i went wrong??
Thanks in advance,
Saravanan.