首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

IE协议扩充,页面中启动程序并传参

2012-09-09 
IE协议扩展,页面中启动程序并传参写注册表,把协议和程序路径写入注册表void CTestDlg::RegIEProtocol(CStr

IE协议扩展,页面中启动程序并传参
写注册表,把协议和程序路径写入注册表

void CTestDlg::RegIEProtocol(CString strProName,CString strPath){HKEY hSubKey;DWORD lpdw;RegCreateKeyEx(HKEY_CLASSES_ROOT,strProName.GetBuffer(0),0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hSubKey,&lpdw);//REG_OPTION_NON_VOLATILE:保存,重启还在;REG_OPTION_VOLATILE:不保存,重启不在。CString strPname = strProName + "Protocol";RegSetValueEx(hSubKey,"",0,REG_SZ,(LPBYTE)strPname.GetBuffer(0),strPname.GetLength());RegSetValueEx(hSubKey,"URL Protocol",0,REG_SZ,(LPBYTE)strPath.GetBuffer(0),strPath.GetLength());HKEY iconKey;CString strIconStr = strPath + ",1";RegCreateKeyEx(hSubKey,"DefaultIcon",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&iconKey,&lpdw);RegSetValueEx(iconKey,"",0,REG_SZ,(LPBYTE)strIconStr.GetBuffer(0),strIconStr.GetLength());RegCloseKey(iconKey);HKEY shellKey;RegCreateKeyEx(hSubKey,"shell",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&shellKey,&lpdw);HKEY openKey;RegCreateKeyEx(shellKey,"open",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&openKey,&lpdw);HKEY commandKey;RegCreateKeyEx(openKey,"command",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&commandKey,&lpdw);CString str = """ + strPath + "" "%1"";RegSetValueEx(commandKey,"",0,REG_SZ,(LPBYTE)str.GetBuffer(0),str.GetLength());RegCloseKey(hSubKey);}


调用:
RegIEProtocol("test","D:\\work\\temp\\activctest\\ocxApp\\TSTCON32.EXE");


IE地址栏中输入:test://
即可启动TSTCON32.EXE

热点排行