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:
varada%netscape.com
2000-03-28 23:19:12 +00:00
parent 24aab1927c
commit 51b42e7d7f
2 changed files with 52 additions and 2 deletions

View File

@@ -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

View File

@@ -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