最近在看一部教程,需要将教程拖到另一个程序上才能播放,但是这个程序每次打开都弹一次网页,很是烦人,于是就做了一个程序拦截。
具体原理就是调用ShellExecute打开程序并把启动参数传递到目标程序上,但打开前先修改HKEY_CLASSES_ROOT\http\shell\open\command下的默认项,使弹出网页的协议暂时失效,之后调用ShellExecute打开程序,等待程序几秒钟(让目标程序执行完成),之后再恢复改注册表键值即可
BOOL CXxxApp::kill() { CRegistry reg(HKEY_CLASSES_ROOT); reg.CreateKey("http\\shell\\open\\command"); if(name=reg.ReadString("")) { reg.Write("","CC"); } return TRUE; } BOOL CXxxApp::retn() { CRegistry reg(HKEY_CLASSES_ROOT); reg.CreateKey("http\\shell\\open\\command"); reg.Write("",name); return TRUE; } BOOL CXxxApp::InitInstance() { AfxEnableControlContainer(); KillProcess("ByPassTlx(JKS).exe"); char *name = GetCommandLine(); char cmdLine[50]={0}; int i =0; for(i; i<(strlen(name)-10); i++) { cmdLine[i] = name[10+i]; } cmdLine[i] = '\0'; kill(); ShellExecute(NULL,"open" , "E:\\Documents and Settings\\xuxu\\桌面\\甲壳虫\\ByPassTlx(JKS).exe", cmdLine, NULL, SW_MINIMIZE ); Sleep(5000); retn(); return FALSE; }
留言