I am trying to convert an html file to image. When it is run in a windows 2008 server the image is created if it is run as administrator. I want to run the program as System. But there is no image created when the program run as system.
the code is below
HBITMAP m_hBmp;
CImage img;
width = bodyWidth;
height = rootHeight > bodyHeight ? rootHeight : bodyHeight;
if(width > 2000)
width = 2000;
if(height > 2000)
height = 2000;
MoveWindow(0,0,width,height,TRUE);
::MoveWindow(m_hwndWebBrowser,0,0,width,height,TRUE);
if(FAILED(m_pBrowser->QueryInterface(IID_IViewObject2,(void**)&pViewObject)))
return FALSE;
CDC *cdcMain = GetDC();
HDC hdcMain = *cdcMain;
HDC hdcMem = CreateCompatibleDC(hdcMain);
m_hBmp = CreateCompatibleBitmap(hdcMain,width,height);
SelectObject(hdcMem,m_hBmp);
RECTL rcBounds = { 0, 0, width, height };
hr = pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL,hdcMain,hdcMem, &rcBounds, NULL, NULL, 0);
img.Attach(m_hBmp);
if(!hr ==img.Save(szDestFilename))
return FALSE;
How can I create image when the program run as system.