# C Program to take a screenshot



## rajsujayks (Jun 23, 2012)

I want to take a screenshot of the current monitor frame using a C program. How do I do it? Any ideas?


----------



## bubusam13 (Jun 23, 2012)

Screen Capture Program | DaniWeb

ok


----------



## rajsujayks (Jun 26, 2012)

bubusam13 said:


> Screen Capture Program | DaniWeb
> 
> ok



This is in C++. I want something in C. I heard we can use a* far *pointer to access the graphics memory. Is it possible to use this to capture the screen..?


----------



## thorton (Jun 26, 2012)

It only uses one C++ standard library function. The rest of it is in C. 

You can't directly access the graphics memory from user mode in Windows. What OS are you using?


----------



## bubusam13 (Jun 26, 2012)

rajsujayks said:


> This is in C++. I want something in C. I heard we can use a* far *pointer to access the graphics memory. Is it possible to use this to capture the screen..?



On what basis u tell its C++, iostream.h ??


----------



## rajsujayks (Jun 28, 2012)

thorton said:


> It only uses one C++ standard library function. The rest of it is in C.
> 
> You can't directly access the graphics memory from user mode in Windows. What OS are you using?



I am using Windows 7 Ultimate 64-bit..



bubusam13 said:


> On what basis u tell its C++, iostream.h ??



Well..it is listed under the C++ section. And none of the functions or statements look like C to me..! 

All I want is to access the VRAM of my graphic card using a C program under Win7 64-bit.. Do you happen to know anything which can help me in this..? I only want to READ values... Not write or modify them...
I know it isn't possible directly under Windows.. But there should be some way..
Anyone..?


----------



## raj_55555 (Jul 19, 2012)

rajsujayks said:


> I am using Windows 7 Ultimate 64-bit..
> 
> 
> 
> ...


You can't just access your VRAM like that. First how do you know which memory block to access?
Not just in windows, but in most other modern OS's you'll get a segfault trying to access random memory locations. Even if by some voodoo you come to know of the address, the virtual memory address vs actual memory address comes into play.
The solution will be OS dependent.

_"I know it isn't possible directly under Windows"_
As far as I remember DOS was the last OS to allow direct access to valid memory blocks. 

If at all possible using C (in windows) it should be with the help of win32 API. You may spend time researching the win32 API. 
Not sure if that will help though, I never did nor suggest time wasting on reinventing the wheel.
Anyways, you can start from here to simulate a printscreen.
And yes, the program from daniweb is a C++ code


----------



## nbaztec (Jul 19, 2012)

Not possible by direct memory access in C for the reasons stated by raj_55555. Your best bet is OS specific API calls.
far pointers are valid only if data resides in user accessible memory (segments, tbp).


----------

