<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 05/20/2013 01:50 PM, 一生有你 wrote:<br>
    </div>
    <blockquote cite="mid:tencent_71DD01F24C8DD9246075C11D@qq.com"
      type="cite">
      <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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
vbox-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</a>
<a class="moz-txt-link-freetext" href="https://www.virtualbox.org/mailman/listinfo/vbox-dev">https://www.virtualbox.org/mailman/listinfo/vbox-dev</a>
</pre>
    </blockquote>
    <br>
    Hello,<br>
    just for interest,<br>
    what was the value of bpp (Bits Per Pixel) in your case?<br>
    <pre class="moz-signature" cols="72">-- 
Valery Portnyagin | VirtualBox Developer | (+7 812) 334 64 26
Oracle Development SPB
10th Krasnoarmeyskaya 22A, Saint-Petersburg, 190103, Russia</pre>
  </body>
</html>