<DIV>I tried to take a screen shot by takecSreenShot(),,but everytime when i trys it, display->TakeScreenShot fails,,and VisualBox.exe crashes....</DIV>
<DIV>I am sure that I can get the correct width and height of the screen "printf("Width: %ul Height: %ul Bits Per Pixel: %ul. ", width,height,bpp);"......</DIV>
<DIV>my vbox and SDK version are the same 4.1.6....</DIV>
<DIV>please help me ...thank U!!</DIV>
<DIV> </DIV>
<DIV>///////here is the code..........bellow</DIV>
<DIV>int testTakeScreenShot(ISession *session)<BR>{<BR> IConsole *console = NULL;<BR> IDisplay *display = NULL;<BR> IFramebuffer* fb=NULL;<BR> unsigned long width, height, bpp;<BR> SIZE_T buffersize;<BR> BYTE* databuff;</DIV>
<DIV> HRESULT rc;<BR> if (session == NULL)<BR> return 1;<BR> /* Get console object. */<BR> rc=session->get_Console(&console);<BR> rc=console->get_Display(&display);</DIV>
<DIV> </DIV>
<DIV> display->GetScreenResolution(0,&width,&height,&bpp);<BR> printf("Width: %ul Height: %ul Bits Per Pixel: %ul. ", width,height,bpp);</DIV>
<DIV> buffersize = width*height*bpp/8;<BR> databuff= (BYTE*)CoTaskMemAlloc(buffersize);</DIV>
<DIV> printf("%p\n", databuff);</DIV>
<DIV><BR> </DIV>
<DIV> // Test databuffer<BR> if (databuff != NULL)<BR> {<BR> rc = display->TakeScreenShot(0,databuff,width,height);</DIV>
<DIV> if (SUCCEEDED(rc))<BR> {<BR> printf("Took a screenshot! %d\n", rc);<BR> }<BR> else<BR> {<BR> printf("Error taking screen shot! rc = 0x%x\n", rc);<BR> }<BR> CoTaskMemFree(databuff);<BR> }<BR> return 0;<BR>}</DIV>