Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: Destro- en 31 Agosto 2011, 06:41 am



Título: Game screenshot win vista/7
Publicado por: Destro- en 31 Agosto 2011, 06:41 am
Holas :).

Hay alguna forma de sacar un screenshot  de un juego en win vista/7 ?.
Con gui sale negra o el escritorio.Estuve biendo con DirectX pero lei que es muy lento y si la img esta en movimiento sale mal :S.

Hay alguna otra forma ?,opengl ?.




gracias :D.


@EDIT
Tambien lei que configurando algunas cosas en la compatibilidad del juego .exe se puede hacer que funcione con gui.Hay alguna forma de configurar eso desde otra aplicacion ?.


Título: Re: Game screenshot win vista/7
Publicado por: WHK en 31 Agosto 2011, 07:34 am
deshabilitando la aceleración de hardware en dxdiag.


Título: Re: Game screenshot win vista/7
Publicado por: Karman en 31 Agosto 2011, 14:25 pm
tenes que llamar a esta API:

http://msdn.microsoft.com/en-us/library/aa969510%28v=vs.85%29.aspx

antes de capturar la pantalla...

Código
  1. bool ManageTheme(bool a){
  2. return (DwmEnableComposition(a?DWM_EC_ENABLECOMPOSITION:DWM_EC_DISABLECOMPOSITION)==S_OK);
  3. }

S2


Título: Re: Game screenshot win vista/7
Publicado por: Eternal Idol en 31 Agosto 2011, 15:18 pm
Muy buen aporte de Karman; si queres que el programa funcione en versiones anteriores de Windows usa enlazado dinamico (LoadLibrary + GetProcAddress).


Título: Re: Game screenshot win vista/7
Publicado por: Destro- en 31 Agosto 2011, 17:27 pm
Gracias a los 2 :D,veo que sale xd.


@EDIT

creo que pude :).pero asta que no instale el msn no voy saber si funciona :S.

Código:
#include <windows.h>
#include <winbase.h>

#include <captura.h>

#define DWM_EC_DISABLECOMPOSITION   0
#define DWM_EC_ENABLECOMPOSITION    1

typedef UINT (CALLBACK* DLLFUNC)(UINT);
DLLFUNC DwmEnableComposition;

bool init_dll();
void fix_win_vis_7(bool enable);

bool is_win_vis_7;

int main()
{
    if(init_dll()) {
        is_win_vis_7 = true;
        MessageBox(NULL, "Dwmapi.dll OK", "test", MB_OK | MB_ICONEXCLAMATION);
    }
    
    Sleep(5000);
    
    if(is_win_vis_7)
        fix_win_vis_7(true);
        
    cap("test.bmp");
    
    if(is_win_vis_7)
        fix_win_vis_7(false);
    
    MessageBox(NULL, "Screenshot sacada", "test", MB_OK | MB_ICONEXCLAMATION);
    
    return 0;
}

void fix_win_vis_7(bool enable)
{
     DwmEnableComposition(enable?DWM_EC_ENABLECOMPOSITION:DWM_EC_DISABLECOMPOSITION);
}

bool init_dll()
{
     HINSTANCE hDLL;
    
     hDLL = LoadLibrary("Dwmapi");
     if(hDLL == NULL)
          return false;

     DwmEnableComposition = (DLLFUNC)GetProcAddress(hDLL, "DwmEnableComposition");

     if(!DwmEnableComposition)
     {
          FreeLibrary(hDLL);
          return false;
     }
     return true;
}


Esta bien ?.