Happy New Year...
The background of the story is that there is a computer in the House, and some little boys are playing at home. Because the computer is used by dad, it's hard to say that some little Butlers are using his baby computer, it is even more difficult for others to play games on their computers.
As a programmer, I am self-reliant and self-developed.
Developed this little thing.
Used
INI File Operations
Registry operations
Process operations
Some UI design (notification bar icon .....)
Software Implementation Functions
Local configuration information, in the INI File
Read and Write the registry, register for startup
The added process can be automatically terminated.
Operation permission and password protection
Software
Rough Program
New Year's Training.
INI File Operations: some code
Read and modify ini key values
For (INT I = 0; I <10; I ++) {cstring indexstr, valuetmp2; indexstr. format ("pressname % d", I); getprivateprofilestring ("killinfo", indexstr, "default", valuetmp2.getbuffer (max_path), max_path, "C :\\ killdata. ini "); If (valuetmp2 = valuetmp) {: writeprivateprofilestring (" killinfo ", indexstr," "," C: \ killdata. ini "); loadinifile (); Return true ;}}
Read and Write Registry Information
Hkey; hkey hkeyroot = HKEY_LOCAL_MACHINE; long ret0 =: regopenkeyex (hkeyroot, "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run", 0, key_all_access, & hkey); If (ret0! = Error_success) // If the hkey cannot be opened, stop the program execution {afxmessagebox ("error: Unable to open the relevant registry information! "); Regclosekey (hkey); Return false;} unsigned char chbuf [100]; DWORD keytype = REG_SZ; // define the data type DWORD datalen = 100; // define the Data Length cstring keyname = _ T ("presskiller"); // The key name to be queried long ret1 =: regqueryvalueex (hkey, keyname, null, & keytype, chbuf, & datalen); cstring tmpvalue; tmpvalue. format ("% s", chbuf); If (ret1! = Error_success) {afxmessagebox ("this registry information is not available. This key value will be created. Please allow this operation! "); // Regclosekey (hkey); // return false;} If (tmpvalue! = Exefilepath) {cstring TMP = exefilepath; lpctstr strvalue = (lpctstr) TMP. getbuffer (TMP. getlength (); long ret =: regsetvalueex (hkey, "presskiller", 0, REG_SZ, (const byte *) strvalue, strlen (TMP) + 1 ); if (Ret! = Error_success) {afxmessagebox ("error: Unable to query the relevant registry information"); regclosekey (hkey); Return false ;}} regclosekey (hkey );
Process operation code:
Handle Han =: createconlhelp32snapshot (th32cs_snapprocess, 0); // process snapshot processentry32 LPP; LPP. dwsize = sizeof (processentry32); bool Bo; Bo =: process32first (Han, & LPP); // obtain the first process information from the snapshot tchar * str1, * str2; while (BO) {str1 = LPP. szexefile; str2 = _ strlwr (str1); cstring pressnametmp = str2; // -----shanghaiaa.exe pressnametmp. makelower (); If (pressnametmp. find (pressname )! =-1) {handle hantmp =: OpenProcess (process_terminate, true, LPP. th32processid); // process instance: terminateprocess (hantmp, 4); // close} Bo =: process32next (Han, & LPP ); // take the following process information}: closehandle (Han); // close the snapshot.
The Code is also rough
The main reason is to expose myself to less-used code.
Completed in one day
Modify the bug within one day and make improvements.
Then we ran on the machine at home...
You have time to maintain it later.
For the program, see the comment address .....
Reprinted please indicate the source
Blog of muxin_hp
Http://blog.csdn.net/xinmuba
Welcome to join us