Click here to Skip to main content
12,500,915 members (54,148 online)
Click here to Skip to main content

Stats

94.3K views
2.4K downloads
48 bookmarked
Posted

Spying on computer usage via keyboard hooks

, 22 Sep 2001
This program can be used to find out how your computer is being used while you are away.
Finding Usage
Section 1
ddd.dsp
ddd.dsw
Section 2
Servpost.dsp
Servpost.dsw
Section3
instks.dsp
instks.dsw
Section4
change.dsp
change.dsw
change.ico
small.ico
//Thanks to Gilas Novik


////   RAS Connect status function
////
////   Written by Gilad Novik
////   For any questions or comments, gilad@bmidas.com


#ifndef _RASSTATUS
#define _RASSTATUS
#include <ras.h>


// We need to declare the functions type
typedef DWORD (WINAPI *RasEnumConnectionsType)(LPRASCONN lprasconn,LPDWORD lpcb,LPDWORD lpcConnections);
typedef DWORD (WINAPI *RasGetConnectStatusType)(HRASCONN hrasconn,LPRASCONNSTATUS lprasconnstatus);

#ifdef _UNICODE
#define RasFileName L"RASAPI32.DLL"
#define RasEnumConnectionsName L"RasEnumConnectionsW"
#define RasGetConnectStatusName L"RasGetConnectStatusW"
#else
#define RasFileName "RASAPI32.DLL"
#define RasEnumConnectionsName "RasEnumConnectionsA"
#define RasGetConnectStatusName "RasGetConnectStatusA"
#endif

BOOL IsRasConnected()
{
	
	HINSTANCE hLib = LoadLibrary(RasFileName);	// Try to load the library
	if (hLib == NULL){
		return FALSE;}	// Return FALSE if we can't find it

	// Get functions address
	RasEnumConnectionsType _RasEnumConnections = (RasEnumConnectionsType)GetProcAddress(hLib,RasEnumConnectionsName);
	RasGetConnectStatusType _RasGetConnectStatus = (RasGetConnectStatusType)GetProcAddress(hLib,RasGetConnectStatusName);
	BOOL bResult = FALSE;
	if (_RasEnumConnections && _RasGetConnectStatus)	// Check if it is valid pointer
	{
		RASCONN RasConn;
		RASCONNSTATUS RasConnStatus;
		RasConnStatus.dwSize = sizeof(RASCONNSTATUS);	// We need to set the size of the structure
		DWORD dwConnSize = sizeof(RASCONN);
		DWORD dwRasCount = 1;	// We only retrieve one connection
		RasConn.dwSize = dwConnSize;	// We need to set the size of the structure
		bResult =	// Let's check it out !!!
			(((*_RasEnumConnections)(&RasConn,&dwConnSize,&dwRasCount)) == 0)
				&& (((*_RasGetConnectStatus)(RasConn.hrasconn,&RasConnStatus)) == 0) 
				&& (RasConnStatus.rasconnstate == RASCS_Connected);
	}
	FreeLibrary(hLib);	// Don't forget to unload the library from memory
	return bResult;
}
#endif // _RASSTATUS

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

H. Joseph
United States United States
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 23 Sep 2001
Article Copyright 2001 by H. Joseph
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid