Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Interrupt calls

Posted on 1998-08-27
12
Medium Priority
?
321 Views
Last Modified: 2010-04-15
I'm working in MSDev Environment. I'm doing inline assembly in my C program. Everything is fine except as soon as I use any Interrupt call my prog. crashes. Why so ?
Also how can I access the video memory of my computer ? Actually I wanna get a dump of my screen.
0
Comment
Question by:ajay_champ
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 1252345
NT prevents you from doing this.

0
 

Author Comment

by:ajay_champ
ID: 1252346
Youngman, Do U mean to say that NT doesn't allows using interrupt calls (like Int 10h) ?
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1252347
Which OS and compiler.

JYoungman is right that you can not access the video memory directly from a 32bit program on NT (Console or GUI).

From VC 1.52 or earlier (the 16 bit compiler) you should be okay,

Additionally are you wanting a console (text mode) or graphics mode dump of the screen.

For a 32bit program:
1. You can get the contents of a console (text) mode window using the GetConsoleScreenBufferInfo API
2. For graphics mode you can get the entire screen into an HBITMAP using the following technique.
i. GetDC on the screen or window you want to capture (call this HDC #1)
ii. Create a compatible bitmap using CreateCompatibleBitmap (call this HBITMAP #2)
iii. Create a compatible DC using CreateCompatibleDC (call this HDC #3)
iv. Select HBITMAP #2 into HDC #3
v. BitBlt from HDC #1 into HDC #3
vi. ReleaseDC HDC #1
vii. HBITMAP #2 now contains the screen shot with HDC#3 associated with it.  You can now use these.  Don't forget to clear them up when done (DeleteDC on the DC, DeleteObject on the bitmap)

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:Bonev
ID: 1252348
Easy way to create device context for the entire screen is:
HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1252349
you got to be careful about which interrupts you call.  Some of them can really p*** off windows.  hehehe,  I know from personal expierence.   If you are working w/ windows, there are functions work-arounds that will do pretty much the same thing and are safer.  ( as safe as windows ever will be)
0
 
LVL 5

Expert Comment

by:laeuchli
ID: 1252350
If you want to use some of the ints, you might have to write a vxd. I would look into that if you really need to use asm in your code
0
 

Author Comment

by:ajay_champ
ID: 1252351
Thanks everybody.
I want a graphics mode dump of a screen. My platforms would be Win 95/NT.
Actually I have noticed one thing. When we do Ctrl-Alt-Print Screen we get the dump of screen in the clipboard. This combination of keys must be calling some API or any other procedure. I wanna know how that could be done ?
0
 

Author Comment

by:ajay_champ
ID: 1252352
Hey no one replied to my last question ?????
0
 
LVL 1

Expert Comment

by:Bonev
ID: 1252353
The question is locked - either accept, or reject the proposed answer.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 150 total points
ID: 1252354
>> I want a graphics mode dump of a screen. My platforms would be Win 95/NT.

Here are the steps

1. Get the size of the screen (in pixels).  You can do this use GetSystemMetrics

int ww = GetSystemMetrics( SM_CXSCREEN ) ; // width
int hh = GetSystemMetrics( SM_CYSCREEN ) ; // height

2. Use GetDC API to get an HDC for the whole screen (call this hDCScreen)

3. Use CreateCompatibleDC to create a memory DC using the values from #1 and  #2 (call this hDCMem)

4. Use CreateCompatibleBitmap to create a bitmap HBITMAP handle (call this hBitmap)

5. SelectObject 4 into 3 ( SelectObject( hDCMem, hBitmap ) ;

6. BitBlt from the screen DC into the memory DC

BitBlt( hDCMem, 0, 0, ww, hh, hDCScreen, 0, 0, SRCCOPY ) ;

7. ReleaseDC on the screen DC

8. You now have a bitmap of the screen (hBitmap) and a DC for it (hDCMem).  When done with these delete the DC (using DeleteDC ) and then delete the bitmap (DeleteObject)

9. You can use BitBlt to copy from the DC to another Windows device (e.g. the printer or your app's window)

10. To put the bitmap on the clipboard
a. DeleteDC on hDCMem
b. OpenClipboard
c. EmptyClipboard
d. SetClipboardData (format is CF_BITMAP, data handle is hBitmap)
e. CloseClipboard
After doing this hBitmap should not be used anymore.



0
 

Author Comment

by:ajay_champ
ID: 1252355
Thanx Answers2000. I'm able to get the dump. But still I 'm facing a problem which is I'm not able to take the dump of that screen into my applications client area.
Right now I'm succeded to take a dump in my Memory DC but unable to get the dump in my application's window's DC which is CWnd::GetDC().
0
 

Author Comment

by:ajay_champ
ID: 1252356
Hey why noone is replying ?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question