¡¡¡¡ÔÚ½øÐÐÈí¼þ¿ª·¢¹ý³ÌÖм䣬ÓкܶàС¹¦ÄܵÄʵÏÖ£¬ËäÈ»ÕâЩ¶«Î÷Äã¿ÉÒÔ²»Ó㬵«ÊÇÈç¹ûÓ¦ÓÃØ콫»áÊÇÄãµÄ³ÌÐò¸ü¾ßÓÐרҵÐÔ¡£
Ò»¡¢ÉèÖóÌÐò×Ô¶¯ÔËÐС£
¡¡¡¡ºÜ¶à¼à¿ØÈí¼þÒªÇóÈí¼þÄܹ»ÔÚϵͳÖØÐÂÆô¶¯ºó²»ÓÃÓû§È¥µã»÷ͼ±êÆô¶¯ÏîÄ¿£¬¶øÊÇÖ±½ÓÄܹ»Æô¶¯ÔËÐУ¬·½·¨ÊÇдע²á±íSoftware\\Microsoft\\Windows\\CurrentVersion\\Run¡£²Î¿¼³ÌÐò¿ÉÒÔ¼ûÏ£º(²éÕÒ³ÌÐòĿ¼µÄÖ´ÐÐÎļþ£¬´æÔÚÔò½øÐÐÌí¼Ó×¢²á±í²Ù×÷)
HKEY RegKey; CString sPath; GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); sPath.ReleaseBuffer(); int nPos; nPos=sPath.ReverseFind('\\'); sPath=sPath.Left(nPos); CString lpszFile=sPath+"\\****.exe";//ÕâÀï¼ÓÉÏÄãÒª²éÕÒµÄÖ´ÐÐÎļþÃû³Æ CFileFind fFind; BOOL bSuccess; bSuccess=fFind.FindFile(lpszFile); fFind.Close(); if(bSuccess) { CString fullName; fullName=lpszFile; RegKey=NULL; RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&RegKey); RegSetValueEx(RegKey,"*****",0,REG_SZ,(const unsigned char*)(LPCTSTR)fullName,fullName.GetLength());//ÕâÀï¼ÓÉÏÄãÐèÒªÔÚ×¢²á±íÖÐ×¢²áµÄÄÚÈÝ this->UpdateData(FALSE); } else { theApp.SetMainSkin(); ::AfxMessageBox("ûÕÒµ½Ö´ÐгÌÐò£¬×Ô¶¯ÔËÐÐʧ°Ü"); exit(0); }
¶þ¡¢×Ô¶¯ÅäÖÃÊý¾ÝÔ´
¡¡¡¡ºÜ¶àµÄ³ÌÐò¶¼ÒªÓõ½Êý¾Ý¿â½áºÏµÄ²Ù×÷£¬ÕâÀï¾ÙÀýACCESS£¬ÒòΪACCESSÔÚÖÐСÐÍVCϵͳ¿ª·¢ÖÐÊÇ×î³£Óõ½µÄ£¬Èç¹û³ÌÐòµÄÒÆÖ²£¬Èç¹û¶ÔÓںܳõ¼¶µÄÓû§À´Ëµ£¬Ä㻹ÐèÒªËûµ½ÅäÖÃÃæ°åÖнøÐÐÊý¾ÝÔ´ÅäÖõĻ°£¬ÄǾÍÓеã˵²»¹ýÈ¥ÁË¡£
#include <odbcinst.h> //ÅäÖÃÊý¾ÝÔ´£¬Êý¾Ý¿âÔÚÓ¦ÓóÌÐòĿ¼ÏÂ,ÕâÀï±ÈÈçÊý¾Ý¿âÎļþÃûΪ***.mdb£¬³ÌÐòÔËÐÐʱºò¿ÉÒÔ½«Êý¾Ý¿âÎļþ¿½±´µ½³ÌÐòĿ¼ÏÂÃæ¡£ CString sPath; GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH); sPath.ReleaseBuffer(); int nPos; nPos=sPath.ReverseFind('\\'); sPath=sPath.Left(nPos); CString lpszFileName = sPath + "\\***.mdb";//ÕâÀïÐ޸ijÉÄãµÄÊý¾Ý¿âÎļþÃû³Æ CFileFind fFind; if(!fFind.FindFile(lpszFileName)) { ::AfxMessageBox("ûÓÐÕÒµ½Êý¾Ý¿â"); exit(0); } CString szDesc; szDesc.Format( "DSN=****;Description=****;DESCRIPTION=The DataBase For ***;FIL=MicrosoftAccess;DEFAULTDIR=%s;DBQ=%s;" ,sPath,lpszFileName);//ÕâÀï***ºÅ¿ÉÒÔÌí¼Ó³ÉÄãµÄÃèÊö
//Ìí¼ÓÊý¾ÝÔ´ if(!::SQLConfigDataSource(NULL,ODBC_ADD_DSN, "Microsoft Access Driver (*.mdb)",(LPCSTR)szDesc)) { ::AfxMessageBox("32λODBCÊý¾ÝÔ´ÅäÖôíÎó!"); exit(0); }
Èý¡¢ÉèÖÃÏÔʾģʽ£º
¡¡¡¡ºÜ¶àµÄ³ÌÐòµÄÒÆÖ²µÄÔËÐл·¾³ÊǸıäµÄ¡£ÓпÉÄÜÄãµÄÔÀ´¿ª·¢»·¾³ÊÇ1024X768£¬µ«Êǵ½ÁËÄÇЩÏÔʾÆ÷´óÓÚ17µÄʱºò£¨·Ö±æÂʳ¬¹ýÄãµÄ¿ª·¢Ê±µÄ·Ö±æÂÊʱ£©£¬³ÌÐòµÄÏÔʾ¿ÉÄܾͲ»ºÃ¿´ÁË¡£
DEVMODE lpDevMode; lpDevMode.dmPelsHeight=768;//Y·½ÏòÏóËصã lpDevMode.dmPelsWidth=1024;//X·½ÏòÏóËصã lpDevMode.dmDisplayFrequency=85;//ÆÁĻˢÐÂÂÊ lpDevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY; ChangeDisplaySettings(&lpDevMode,0);
ËÄ¡¢ÔÚÄãµÄ³ÌÐòÖмä¼ÓÔØÆäËûÓ¦ÓóÌÐò£º
¡¡¡¡ÄãµÄ³ÌÐò³ýÁ˵÷Óõ½¸÷¸öÄ£¿é½øÐÐÐͬ¹¤×÷Í⣨DLL£©£¬»¹ÓпÉÄܵ÷Óò»ÊÇͬһ¸ö¿ª·¢»·¾³ÏµÄÓ¦ÓóÌÐò£¬±ÈÈçVC»·¾³Ïµ÷ÓÃDELPHI£¬VB¿ª·¢µÄÖ´ÐгÌÐò£¬Äã¾Í¿ÉÒÔÓõ½ÏÂÃæµÄ·½·¨£¨½«µ÷ÓõÄÓ¦ÓóÌÐò¿½±´³ÌÐòĿ¼ÖУ©£º
CString sPath; GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH); sPath.ReleaseBuffer(); int nPos; nPos=sPath.ReverseFind('\\'); sPath=sPath.Left(nPos); CString lpszFileName = sPath + "\\***.exe";//ÕâÀïÐ޸ijÉÄãµÄµ÷ÓÃÓ¦ÓóÌÐòµÄÎļþÃû³Æ CFileFind fFind; if(!fFind.FindFile(lpszFileName)) { ::AfxMessageBox("ûÓÐÕÒµ½µ÷ÓõÄÓ¦ÓóÌÐò£¡"); return FALSE; } else ShellExecute(NULL,NULL,_T("***.exe"),NULL,sPath,NULL);
Îå¡¢½áÊø½ø³Ì£º
¡¡¡¡ÔÚÄãµÄ³ÌÐòÖнáÊø±ðµÄ³ÌÐò½ø³Ì£¬²ÉÓõķ½·¨ÊǽøÐнø³ÌÁо٣¬È»ºó²ÉÓòéÕҵķ½·¨½øÐУº
#include "TLHELP32.H" DWORD ProcessID[50]; CString kkk[50]; HANDLE SnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32* info=new PROCESSENTRY32; PROCESSENTRY32 ProcessInfo;//ÉùÃ÷½ø³ÌÐÅÏ¢±äÁ¿ ProcessInfo.dwSize=sizeof(ProcessInfo);//ÉèÖÃProcessInfoµÄ´óС //·µ»ØϵͳÖеÚÒ»¸ö½ø³ÌµÄÐÅÏ¢ BOOL Status=Process32First(SnapShot,&ProcessInfo); int m_nProcess=0; while(Status) { CString s,str1,str2; s.Format("%d",ProcessInfo.cntThreads); str1.Format("%s",ProcessInfo.szExeFile); str1=ProcessInfo.szExeFile; kkk[m_nProcess]=ProcessInfo.szExeFile; ProcessID[m_nProcess]=ProcessInfo.th32ProcessID; if(str1=="***.exe")//***.exe¾ÍÊÇÄãÒª½áÊøµÄ½ø³ÌµÄÃû³Æ { HANDLE ProcessHandle; ProcessHandle=OpenProcess (PROCESS_ALL_ACCESS,FALSE,ProcessID[m_nProcess]); TerminateProcess(ProcessHandle,0); } Status=Process32Next(SnapShot,&ProcessInfo); m_nProcess++; }
|