Might be even easier to set up your firewall to block the msn ports at certain times of the day so it won't connect, but really, your parents should try being actual parents and do something about it. Transparently blocking it is not the way to do it. If they lay down rules saying no computer/internet after x oclock, and enforce those rules it will be better for everyone.
When I was young my dad would take the modem cord from my computer if I was ever on it past when I should have. What ever happened to decent parenting, nowadays the mall and movie theatre are the baby sitters.
limiting acess to programs
GotenRulezU - when we had dial up we banned her from msn for a week(after she was on for about 7 hours 1 day) When we got broadband she was hyper. stealing the power cord, will make her more addicted.
Ace826 - my sister is a retard. but I don't have a spare computer though. "sounds like a good prooject." I agree, always good experiance.
DrEvil - I don't really want to limit the time of day, but I could probably do it. I wish my mum would try harder, but my sister is that sort of age and hates everybody.
Still havn't found anything yet. It can't be that hard o monitor the processes. Loads of progs do it. Ad-aware for one
Ace826 - my sister is a retard. but I don't have a spare computer though. "sounds like a good prooject." I agree, always good experiance.
DrEvil - I don't really want to limit the time of day, but I could probably do it. I wish my mum would try harder, but my sister is that sort of age and hates everybody.
Still havn't found anything yet. It can't be that hard o monitor the processes. Loads of progs do it. Ad-aware for one
I found I site that deals with this. www.codeguru.com
I have go a basic prog working in a console application, it uses the system namespace. What I need to do is to get it working without a window.
I have go a basic prog working in a console application, it uses the system namespace. What I need to do is to get it working without a window.
If would be nice if you showed me some code(On how to get the processlist that is).
Next, make it a Win32 application that runs without a window(Just create the window, but ShowWindow(SW_HIDE); after creating it. This will prevent her from closing since it will not even show up on the taskbar.
Next step is to set up a WM_TIMER event that fires every 5 or 10 seconds. When you receive the WM_TIMER, grab the active process list, check for "msnmsgr.exe" and when found, kill it.
A next step in the process is to add a config file which you store somewhere in the windows directory with the "allow times". For instance, 16:00 to 19:00 is MSN time.
After this, your application is sorta ready for a simple beta test. Install it, add it to the startup folder or add it as a system service.
As a last step, you can add a little GUI to it to edit the times on which MSN is allowed and when not(Or something along those lines). When you decide to do this, make sure you allow application to run only ONCE(In this case, make it a System Service) with a bunch of parameters. When started with block.exe -gui it shows a password box in which you need to enter the password to gain access. And ofcourse:
-start
-restart
-stop
-install
-uninstall
Store the password as an MD5 hash in the file and you got yourself a nice little MSN blocker application. Ofcourse, you could even expand this further and make the list of blocked applications variable.
Toolmaker
Next, make it a Win32 application that runs without a window(Just create the window, but ShowWindow(SW_HIDE); after creating it. This will prevent her from closing since it will not even show up on the taskbar.
Next step is to set up a WM_TIMER event that fires every 5 or 10 seconds. When you receive the WM_TIMER, grab the active process list, check for "msnmsgr.exe" and when found, kill it.
A next step in the process is to add a config file which you store somewhere in the windows directory with the "allow times". For instance, 16:00 to 19:00 is MSN time.
After this, your application is sorta ready for a simple beta test. Install it, add it to the startup folder or add it as a system service.
As a last step, you can add a little GUI to it to edit the times on which MSN is allowed and when not(Or something along those lines). When you decide to do this, make sure you allow application to run only ONCE(In this case, make it a System Service) with a bunch of parameters. When started with block.exe -gui it shows a password box in which you need to enter the password to gain access. And ofcourse:
-start
-restart
-stop
-install
-uninstall
Store the password as an MD5 hash in the file and you got yourself a nice little MSN blocker application. Ofcourse, you could even expand this further and make the list of blocked applications variable.
Toolmaker
Ok here is my code:
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <windows.h>
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
Diagnostics::Process *p[]=Diagnostics::Process::GetProcessesByName("msnmsgr");
// this gets the process details for msnmsgr.
// to get all processes use
// Diagnostics::Process *p[]=Diagnostics::Process::GetProcesses();
Console::WriteLine("Found: ");
Console::WriteLine(p->get_Length());
for (int i = 0; i<p->get_Length();i++)
{
Console::WriteLine(p->ProcessName);
Console::WriteLine("Terminating...");
HANDLE h = OpenProcess(PROCESS_ALL_ACCESS,true,p->get_Id());
//this gets a handle to the process
if (TerminateProcess(h,1)) // terminates process
{
Console::WriteLine("terminated");
}
else
{
Console::WriteLine("error");
}
}
return 0;
}
This works fine on my laptop, but not on any other pc so far. I think it may be a problem with the system files or something. Everyone else gets a "application error"
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <windows.h>
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
Diagnostics::Process *p[]=Diagnostics::Process::GetProcessesByName("msnmsgr");
// this gets the process details for msnmsgr.
// to get all processes use
// Diagnostics::Process *p[]=Diagnostics::Process::GetProcesses();
Console::WriteLine("Found: ");
Console::WriteLine(p->get_Length());
for (int i = 0; i<p->get_Length();i++)
{
Console::WriteLine(p->ProcessName);
Console::WriteLine("Terminating...");
HANDLE h = OpenProcess(PROCESS_ALL_ACCESS,true,p->get_Id());
//this gets a handle to the process
if (TerminateProcess(h,1)) // terminates process
{
Console::WriteLine("terminated");
}
else
{
Console::WriteLine("error");
}
}
return 0;
}
This works fine on my laptop, but not on any other pc so far. I think it may be a problem with the system files or something. Everyone else gets a "application error"
No, it's because it's managed C++. That code requires the .NET framework to be installed on the computers. Convert the code to unmanaged C++(Ditch mscoree.dll for instance) and try using the regular Win32 API.
I'll try to have a little peak tomorrow, if I got the time. I'm off to bedski now.
Toolmaker
I'll try to have a little peak tomorrow, if I got the time. I'm off to bedski now.
Toolmaker
Yeah, I assumed it might be the .net framework. I am not to sure about the managed/unmanaged part of it. If you could show me roughly how to do it, i wud work it out from there. If I can't do it, I can just install .net framework on the relevant pc. and not make it for anyone else. just for the function i want.
ok got .net framework and it works. What is the differenace between managed and not?
other than garbage collection
other than garbage collection
Quote:Original post by crazy_andy
ok got .net framework and it works. What is the differenace between managed and not?
other than garbage collection
The syntax and the library they use.
I wrote a very simple processlist viewer in normal C++ using the Win32 API. It's easier to understand than the managed code and you can easily turn this into an std::list of std::string's. Iterating though the list will be easy.
This is the code:
If you need help, you know where to find the PM button.
Toolmaker
This is the code:
#include <windows.h>#include <tlhelp32.h>#include <iostream>#include <conio.h>using namespace std;int main(){ HANDLE hSnapshot; PROCESSENTRY32 ProcessEntry; // Get system snapshot before we can walk over all the processes hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) { cout << "Invalid snapshot handle!" << endl; return (0); } ZeroMemory(&ProcessEntry, sizeof(PROCESSENTRY32)); ProcessEntry.dwSize = sizeof(PROCESSENTRY32); // grab the first process if (!Process32First(hSnapshot, &ProcessEntry)) { CloseHandle(hSnapshot); cout << "Failed to get first process" << endl; return (0); } // Display process information do { cout << "Process name: " << ProcessEntry.szExeFile << endl; } while(Process32Next(hSnapshot, &ProcessEntry)); CloseHandle(hSnapshot); cout << "Done!" << endl; getch(); return (0);}
If you need help, you know where to find the PM button.
Toolmaker
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement