CPI_Player_FileAssoc.c
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:3k
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_Player_CoDec.h"
- typedef struct _CPs_FileAssociation
- {
- char* m_pcExtension;
- DWORD m_dwCookie;
- void* m_pNext;
- } CPs_FileAssociation;
- //
- void CPFA_InitialiseFileAssociations(CPs_CoDecModule* pCoDec)
- {
- pCoDec->m_pFileAssociationCookie = NULL;
- }
- void CPFA_EmptyFileAssociations(CPs_CoDecModule* pCoDec)
- {
- CPs_FileAssociation* pCursor = (CPs_FileAssociation*)pCoDec->m_pFileAssociationCookie;
- CPs_FileAssociation* pNext;
- while(pCursor)
- {
- CP_CHECKOBJECT(pCursor);
- pNext = (CPs_FileAssociation*)pCursor->m_pNext;
- free(pCursor->m_pcExtension);
- free(pCursor);
- pCursor = pNext;
- }
- }
- void CPFA_AddFileAssociation(CPs_CoDecModule* pCoDec, const char* pcExtension, DWORD dwCookie)
- {
- CPs_FileAssociation* pNewAssociation = (CPs_FileAssociation*)malloc(sizeof(CPs_FileAssociation));
- CPs_FileAssociation* pCursor = (CPs_FileAssociation*)pCoDec->m_pFileAssociationCookie;
- while(pCursor)
- {
- if(stricmp(pcExtension, pCursor->m_pcExtension) == 0)
- {
- CP_TRACE1("** Extension "%s" already registered here", pcExtension);
- return;
- }
- pCursor = (CPs_FileAssociation*)pCursor->m_pNext;
- }
- STR_AllocSetString(&pNewAssociation->m_pcExtension, pcExtension, FALSE);
- pNewAssociation->m_dwCookie = dwCookie;
- pNewAssociation->m_pNext = pCoDec->m_pFileAssociationCookie;
- pCoDec->m_pFileAssociationCookie = pNewAssociation;
- }
- //
- BOOL CPFA_IsAssociated(CPs_CoDecModule* pCoDec, const char* pcExtension, DWORD* pdwCookie)
- {
- CPs_FileAssociation* pCursor = (CPs_FileAssociation*)pCoDec->m_pFileAssociationCookie;
- while(pCursor)
- {
- CP_CHECKOBJECT(pCursor);
- if(stricmp(pcExtension, pCursor->m_pcExtension) == 0)
- {
- *pdwCookie = pCursor->m_dwCookie;
- return TRUE;
- }
- pCursor = (CPs_FileAssociation*)pCursor->m_pNext;
- }
- return FALSE;
- }
- void CPFA_AssociateWithEXE(CPs_CoDecModule* pCoDec)
- {
- CPs_FileAssociation* pCursor = (CPs_FileAssociation*)pCoDec->m_pFileAssociationCookie;
- HKEY hKey;
- DWORD dwDisposition;
- while(pCursor)
- {
- char* pDotExt;
- CP_CHECKOBJECT(pCursor);
- pDotExt = (char*)malloc(strlen(pCursor->m_pcExtension) + 2);
- pDotExt[0] = '.';
- strcpy(pDotExt + 1, pCursor->m_pcExtension);
- CP_TRACE1("Associating extension: "%s"", pCursor->m_pcExtension);
- RegCreateKeyEx(HKEY_CLASSES_ROOT, pDotExt, 0, NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS, NULL, &hKey,
- &dwDisposition);
- RegSetValueEx(hKey, NULL, 0, REG_SZ, CIC_COOLPLAYER_FILETYPE, sizeof(CIC_COOLPLAYER_FILETYPE));
- RegCloseKey(hKey);
- free(pDotExt);
- pCursor = (CPs_FileAssociation*)pCursor->m_pNext;
- }
- }
- //