Windows API Programing....

Posted by vs4vijay on Stack Overflow See other posts from Stack Overflow or by vs4vijay
Published on 2010-05-01T16:17:05Z Indexed on 2010/05/01 16:27 UTC
Read the original article Hit count: 224

Filed under:
|
|

Hello There...

Its me Vijay..

I m Trying to make a CrossHair(some kind of cursor) On The Screen while running a Game (Counter Strike)...

so i did this...

#############################

#include<iostream.h>
#include<windows.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<process.h>
#include <time.h>
int main()
{
HANDLE hl = OpenProcess(PROCESS_ALL_ACCESS,TRUE,pid); // Here pid is the process ID of the Game...
HDC hDC = GetDC(NULL); //Here i pass NULL for Entire Screen...
HBRUSH hb=CreateSolidBrush(RGB(0,255,255)); SelectObject(hDC,hb); POINT p; while(!kbhit())
{
int x=1360/2,y=768/2;
MoveToEx(hDC,x-20,y,&p);
LineTo(hDC,x+20,y);

       SetPixel(hDC,x,y,RGB(255,0,0));
       SetPixel(hDC,x-1,y-1,RGB(255,0,0));
       SetPixel(hDC,x-1,y+1,RGB(255,0,0));
       SetPixel(hDC,x+1,y+1,RGB(255,0,0));
       SetPixel(hDC,x+1,y-1,RGB(255,0,0));

       MoveToEx(hDC,x,y-20,&p);

       LineTo(hDC,x,y+20);                         
}

cin.get();
return 0;

} ####################################

it works fine....at desktop i see crosshair...but my problem is that when i run game...the cross here got disappeared....

so i think i did not handle the process of game...

so i pass the HANDLE to the GetDC(hl)...

But GetDC take only HWND(Handle To Window)...

so i typecast it like this...

HWND hl = (HWND)OpenProcess(PROCESS_ALL_ACCESS,TRUE,pid);

and passed hl to the GetDC(hl)...

but it doesnt work...Whats wrong with the code...

plz tell me how do i make a simple shape at the screen on a process or game...

PS : (My Compiler Is DevCPP and OS WinXP SP3....)

© Stack Overflow or respective owner

Related posts about api

Related posts about Windows