ShellExecute fails - why? 
Author Message
 ShellExecute fails - why?

Hello!

 I'm trying to show a file selected from a list using shellexecute:

HINSTANCE hInstance =
ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

This always failes and hInstance is always 0x1f indiacting error
SE_ERR_NOASSOC: There is no application associated with the given filename
extension. However this is a .c file... DevStudio should manage that.

Please help!

-H



Fri, 22 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?

Quote:

>Hello!

> I'm trying to show a file selected from a list using shellexecute:

>HINSTANCE hInstance =
>ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

>This always failes and hInstance is always 0x1f indiacting error
>SE_ERR_NOASSOC: There is no application associated with the given filename
>extension. However this is a .c file... DevStudio should manage that.

Who says DevStudio should manage it? I personally have .C files associated with
Wordpad.
Anyway, if there's no associated application, there's no associated
application, as you yourself wrote. You'll need to go to explorer View |
Options | File Types | New Type... (at least that's the menu items, tabs and
buttons on my Win95 explorer.)

Regards,
--
Adrian M. Whatley
Universitaet/ETH Zuerich,
Institut fuer Neuroinformatik,
Winterthurerstrasse 190,
CH-8057 Zuerich, Switzerland.
Phone: +41 1 635 3067  Fax: +41 1 635 3053



Fri, 22 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?
Haavard,

Quote:
>  I'm trying to show a file selected from a list using shellexecute:

> HINSTANCE hInstance =
> ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

> This always failes and hInstance is always 0x1f indiacting error
> SE_ERR_NOASSOC: There is no application associated with the given filename
> extension. However this is a .c file... DevStudio should manage that.

Have you verified (using Explorer) that the .c file is actually associated to
msdev.exe? I recall seeing that VC++ setup sometimes didn't correctly associate
some files....

--
Tomas Restrepo

http://members.xoom.com/trestrep/



Fri, 22 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?


Quote:
> Haavard,
> >  I'm trying to show a file selected from a list using shellexecute:

> > HINSTANCE hInstance =

ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

Quote:

> > This always failes and hInstance is always 0x1f indiacting error
> > SE_ERR_NOASSOC: There is no application associated with the given
filename
> > extension. However this is a .c file... DevStudio should manage that.

> Have you verified (using Explorer) that the .c file is actually associated
to
> msdev.exe? I recall seeing that VC++ setup sometimes didn't correctly
associate
> some files....

I doubleclick on the file and it shows up in devstudio. Isn't this prof
enough?
(I've doublechecked in the filemanager file assosiation.)

-H



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?
Haavard N. Jakobsen:

Quote:
> I doubleclick on the file and it shows up in devstudio. Isn't this prof
> enough?
> (I've doublechecked in the filemanager file assosiation.)

The verb used by DevStudio is "&Open with MSDEV".

This is the string you would have to use as the verb to open the file in
DevStudio using ShellExecute.

The relevent registry keys are:


[HKEY_CLASSES_ROOT\cfile\shell\&Open with MSDEV\command]
...

note that there is no [...\shell\open\...] key. The keynames following
"shell" are the valid verbs that can be used in shellexecute for files of
that class.

Chris
--
Please keep newsgroup correspondence within the newsgroups.

<http://www.mvps.org/vcfaq> Visual C & Win32 FAQ
<http://users.lia.net/chris/win32> My Win32 Development Page



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?


Quote:
> Haavard N. Jakobsen:
> > I doubleclick on the file and it shows up in devstudio. Isn't this prof
> > enough?
> > (I've doublechecked in the filemanager file assosiation.)

> The verb used by DevStudio is "&Open with MSDEV".

> This is the string you would have to use as the verb to open the file in
> DevStudio using ShellExecute.

> The relevent registry keys are:

> [HKEY_CLASSES_ROOT\.c]

> [HKEY_CLASSES_ROOT\cfile\shell\&Open with MSDEV\command]
> ...

> note that there is no [...\shell\open\...] key. The keynames following
> "shell" are the valid verbs that can be used in shellexecute for files of
> that class.

How can I check this in a general way? Do I have to write code for
every IDE or can I assume that the first subkey under shell is used to
open the file?

-H



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?

Quote:



>> Haavard N. Jakobsen:
>> > I doubleclick on the file and it shows up in devstudio. Isn't this prof
>> > enough?
>> > (I've doublechecked in the filemanager file assosiation.)

>> The verb used by DevStudio is "&Open with MSDEV".

>> This is the string you would have to use as the verb to open the file in
>> DevStudio using ShellExecute.

>> The relevent registry keys are:

>> [HKEY_CLASSES_ROOT\.c]

>> [HKEY_CLASSES_ROOT\cfile\shell\&Open with MSDEV\command]
>> ...

>> note that there is no [...\shell\open\...] key. The keynames following
>> "shell" are the valid verbs that can be used in shellexecute for files of
>> that class.

>How can I check this in a general way? Do I have to write code for
>every IDE or can I assume that the first subkey under shell is used to
>open the file?

>-H

When there are multiple verbs defined, then if the default value of the
...\shell key is defined, this tells you which of the verbs is the default,
otherwise it's the first in the list.
Experiment a bit with Explorer | View Options | File Types and look to see what
happens in the registry. (That's how I just derived the above rule.)
The problem is, you still don't know whether the default has been set by the
user to be a verb that opens the file in question in some editor or not.

--
--
Adrian M. Whatley
Universitaet/ETH Zuerich,
Institut fuer Neuroinformatik,
Winterthurerstrasse 190,
CH-8057 Zuerich, Switzerland.
Phone: +41 1 635 3067  Fax: +41 1 635 3053



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?

Quote:

> How can I check this in a general way? Do I have to write code for
> every IDE or can I assume that the first subkey under shell is used to
> open the file?

Testing on windows 2000, the shell sorts the items alphabetically, and uses
the lowest one.

That is, if the default verb is not specified as the default value of the
"shell" key.

This registry entry will ensure that MSDEV is the default (ie dbl-click)
handler for .c files no matter what other verb are "installed":


It is unfortunate that MSDEV does not support the "open" verb properly, thus
preventing ShellExecute from behaving in the way the documentation tries to
claim it should.

Chris

--
Please keep newsgroup correspondence within the newsgroups.

<http://www.mvps.org/vcfaq> Visual C & Win32 FAQ
<http://users.lia.net/chris/win32> My Win32 Development Page



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?


Quote:
> I'm trying to show a file selected from a list using shellexecute:

>HINSTANCE hInstance =
>ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

>This always failes and hInstance is always 0x1f indiacting error
>SE_ERR_NOASSOC: There is no application associated with the given filename
>extension. However this is a .c file... DevStudio should manage that.

Here's a possibility. This only works if the registry key that defines the
association has the name "open". Even if its value (the thing that gets
displayed in the context menu) may be "Open", if the key is called, say

HKCR\c_file\shell\dsopen

the line you showed won't work (I guess ..."dsopen"... would). As an example,
look at the file type cplfile in the standard W9x installation.

--
Dirk Fieldhouse                 Logica UK Limited

c=gb;a=attmail;p=logica;        London NW1 2PL
o=LOGICA;ou1=UK;s=fieldhouse    UK
+44 (171) 637 9111



Sat, 23 Feb 2002 03:00:00 GMT  
 ShellExecute fails - why?
Dana Mon, 6 Sep 1999 16:56:54 +0200, "Haavard N. Jakobsen"

Quote:
>Hello!

> I'm trying to show a file selected from a list using shellexecute:

>HINSTANCE hInstance =
>ShellExecut(m_hWnd,"open",szSourceFileName,NULL,szDirectory,SW_SHOWNORMAL);

>This always failes and hInstance is always 0x1f indiacting error
>SE_ERR_NOASSOC: There is no application associated with the given filename
>extension. However this is a .c file... DevStudio should manage that.

DevStudio has nothing to do with it - DevStiduo Setup should set the
associations. After that, *Windows* calls devstudio with a specified
filename. Maybe you didn't install Devstudio correctly?


Sun, 24 Feb 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. ShellExecute fails when using SHGetSpecialFolderLocation?

2. Why is this failing?

3. why does this if statement fail ?

4. Why the application failed to start?

5. why does fopen fail?

6. Why realloc() failed

7. Why does my C Realloc() fail?

8. Why does this fail?

9. malloc failed but calloc worked, why?

10. why does this fread fail, trying to read 100,000 rec in one fread

11. Why fopen fails?

12. why Advise failed?

 

 
Powered by phpBB® Forum Software