落鹤生:为EasyPlayer做了安装包,但是文件类型关联一直存在问题,这个是用VC来进行关联的代码,最好还是在Install Shield里或者SetFactory里进行关联,等回头找到解决方案了再补充上来吧。
文件关联,网上资料不多,提供了两个简单的函数,使用方便。
- #include <windows.h>
- #include <stdio.h>
-
-
-
-
-
- BOOL CheckFileRelation(const char *strExt, const char *strAppKey)
- {
- int nRet=FALSE;
- HKEY hExtKey;
- char szPath[_MAX_PATH];
- DWORD dwSize=sizeof(szPath);
- if(RegOpenKey(HKEY_CLASSES_ROOT,strExt,&hExtKey)==ERROR_SUCCESS)
- {
- RegQueryValueEx(hExtKey,NULL,NULL,NULL,(LPBYTE)szPath,&dwSize);
- if(_stricmp(szPath,strAppKey)==0)
- {
- nRet=TRUE;
- }
- RegCloseKey(hExtKey);
- return nRet;
- }
- return nRet;
- }
-
-
-
-
-
-
-
- void RegisterFileRelation(char *strExt, char *strAppName, char *strAppKey
- , char *strDefaultIcon, char *strDescribe)
- {
- char strTemp[_MAX_PATH];
- HKEY hKey;
-
- RegCreateKey(HKEY_CLASSES_ROOT,strExt,&hKey);
- RegSetValue(hKey,"",REG_SZ,strAppKey,strlen(strAppKey)+1);
- RegCloseKey(hKey);
-
- RegCreateKey(HKEY_CLASSES_ROOT,strAppKey,&hKey);
- RegSetValue(hKey,"",REG_SZ,strDescribe,strlen(strDescribe)+1);
- RegCloseKey(hKey);
-
- sprintf(strTemp,"%s//DefaultIcon",strAppKey);
- RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
- RegSetValue(hKey,"",REG_SZ,strDefaultIcon,strlen(strDefaultIcon)+1);
- RegCloseKey(hKey);
-
- sprintf(strTemp,"%s//Shell",strAppKey);
- RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
- RegSetValue(hKey,"",REG_SZ,"Open",strlen("Open")+1);
- RegCloseKey(hKey);
-
- sprintf(strTemp,"%s//Shell//Open//Command",strAppKey);
- RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
- sprintf(strTemp,"%s /"%%1/"",strAppName);
- RegSetValue(hKey,"",REG_SZ,strTemp,strlen(strTemp)+1);
- RegCloseKey(hKey);
- }
(落鹤生) |