fix for bug #32124 making the default application open the file depending on the extension
git-svn-id: svn://10.0.0.236/trunk@64401 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -288,7 +288,7 @@ BOOL CInterpret::IterateListBox(char *parms)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CInterpret::GetRegistryKey( HKEY key, char *subkey, char *retdata )
|
||||
BOOL CInterpret::GetRegistryKey( HKEY key, const char *subkey, char *retdata )
|
||||
{
|
||||
long retval;
|
||||
HKEY hkey;
|
||||
@@ -343,6 +343,47 @@ BOOL CInterpret::OpenBrowser(const char *url)
|
||||
return retflag;
|
||||
}
|
||||
|
||||
BOOL CInterpret::OpenViewer(const char *url)
|
||||
{
|
||||
CString file2Open = url;
|
||||
int filelength = file2Open.GetLength();
|
||||
int findext = file2Open.ReverseFind('.');
|
||||
int extlength = filelength - findext;
|
||||
CString fileExtension = file2Open.Right(extlength);
|
||||
|
||||
char key[MAX_SIZE + MAX_SIZE];
|
||||
BOOL retflag = FALSE;
|
||||
|
||||
/* get the .htm regkey and lookup the program */
|
||||
if(GetRegistryKey(HKEY_CLASSES_ROOT,(LPCTSTR)fileExtension,key) == ERROR_SUCCESS)
|
||||
{
|
||||
lstrcat(key,"\\shell\\open\\command");
|
||||
if(GetRegistryKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
|
||||
{
|
||||
char *pos;
|
||||
pos = strstr(key,"\"%1\"");
|
||||
if(pos == NULL) /* if no quotes */
|
||||
{
|
||||
/* now check for %1, without the quotes */
|
||||
pos = strstr(key,"%1");
|
||||
if(pos == NULL) /* if no parameter */
|
||||
pos = key+lstrlen(key)-1;
|
||||
else
|
||||
*pos = '\0'; /* remove the parameter */
|
||||
}
|
||||
else
|
||||
*pos = '\0'; /* remove the parameter */
|
||||
|
||||
lstrcat(pos," ");
|
||||
lstrcat(pos,url);
|
||||
ExecuteCommand(key,SW_SHOW,50);
|
||||
retflag = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return retflag;
|
||||
}
|
||||
|
||||
void CInterpret::GenerateList(CString action, WIDGET* curWidget, CString parentDirPath)
|
||||
{
|
||||
CFileFind fileList;
|
||||
@@ -779,6 +820,14 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
|
||||
OpenBrowser((CHAR*)(LPCTSTR)Location);
|
||||
}
|
||||
|
||||
else if (strcmp(pcmd, "OpenViewer") == 0)
|
||||
{
|
||||
// This is to dsiplay an image in a separate dialog
|
||||
CString Location = replaceVars(parms,NULL);
|
||||
OpenViewer((CHAR*)(LPCTSTR)Location);
|
||||
}
|
||||
|
||||
|
||||
else if (strcmp(pcmd, "ViewFile") == 0)
|
||||
{
|
||||
// This is to dsiplay an image in a separate dialog
|
||||
|
||||
@@ -48,8 +48,9 @@ public:
|
||||
BOOL CallDLL(char *dll, char *proc, char *parms, WIDGET *curWidget);
|
||||
BOOL interpret(char *cmds, WIDGET *curWidget);
|
||||
BOOL interpret(CString cmds, WIDGET *curWidget);
|
||||
BOOL CInterpret::GetRegistryKey( HKEY key, char *subkey, char *retdata );
|
||||
BOOL CInterpret::GetRegistryKey( HKEY key, const char *subkey, char *retdata );
|
||||
BOOL CInterpret::OpenBrowser(const char *url);
|
||||
BOOL CInterpret::OpenViewer(const char *url);
|
||||
CString CInterpret::GetTrimFile(CString filePath);
|
||||
|
||||
// Overrides
|
||||
|
||||
Reference in New Issue
Block a user