File Association in Dialog-Based Application

Has anyone seen any info on how to associated a file type with my 
dialog-based application?

In order to use RegisterShellFileTypes(), I must add my document template 
using AddDocTemplates(). But AddDocTemplates() can't be called without a 
CDocument class.

Thanks for any thoughts.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
10/25/2008 7:35:27 PM
vc.mfc 33608 articles. 0 followers. Follow

36 Replies
725 Views

Similar Articles

[PageSpeed] 22

>Has anyone seen any info on how to associated a file type with my 
>dialog-based application?
>
>In order to use RegisterShellFileTypes(), I must add my document template 
>using AddDocTemplates(). But AddDocTemplates() can't be called without a 
>CDocument class.

Jonathan,

I think you just have to do it by adding the registry values manually
(or through your application's setup program).

See "File Types" in MSDN.

Dave
0
davidl7375 (2060)
10/25/2008 9:48:43 PM
One "modern" problem is that some users don't have access to this part of 
the registry these days since it usually requires administrator privileges. 
We've taken to adding these things in our setup programs because those are 
typically run administrators anyway.  Even the main code in MFC fails for 
many applications, you just don't see it because it fails elegantly (just 
doesn't always work as expected).

I think this may be better under Vista because I think the associations 
there are under HKCU rather than HKCR.

If it were me, I'd just write a small routine to add the associations in 
myself.

Here's some code I use, but it hasn't been updated for Vista and assumes 
administrator privileges for at least one running of my program:

void CMyApp::AddXXXRegistryType(void)
{
     Registry qdReg(HKEY_CLASSES_ROOT, _T(".xxx"),true,false);
     Registry qdRegMyKey(HKEY_CLASSES_ROOT,_T("MyApp.MyKey"),true,false);
     Registry 
qdRegDefaultIcon(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\DefaultIcon"),true,false);
     Registry 
qdRegShellCommand(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\Shell\\Open\\Command"),true,false);
     CString csProgramPath, csDefaultIcon, csCommand;
     AfxGetModuleShortFileName(AfxGetInstanceHandle(), csProgramPath);
     csDefaultIcon = csProgramPath + _T(",28"); // Index of icon in EXE
     csCommand = csProgramPath + _T(" \"%1\"");

     if (qdReg.IsValidKey()) {
          bool bSuccess = qdReg.SetString(_T(""), _T("MyApp.MyKey"));
          bSuccess = qdRegMyKey.SetString(_T(""),_T("MyApp.MyKey));
          bSuccess = qdRegMyKey.SetInt(_T("EditFlags"),0);
          bSuccess = qdRegDefaultIcon.SetString(_T(""),csDefaultIcon);
          bSuccess = qdRegShellCommand.SetString(_T(""),csCommand);
     }
     else
          LogEvent("HKEY_CLASSES_ROOT\\.xxx reg key not valid");
}

Tom

"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:uBAcXjtNJHA.588@TK2MSFTNGP06.phx.gbl...
> Has anyone seen any info on how to associated a file type with my 
> dialog-based application?
>
> In order to use RegisterShellFileTypes(), I must add my document template 
> using AddDocTemplates(). But AddDocTemplates() can't be called without a 
> CDocument class.
>
> Thanks for any thoughts.
>
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 

0
tom.nospam (3240)
10/26/2008 4:20:43 PM
Thanks. I just didn't have much info on making the required registry changes 
in a way that would be reliable long-term.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"David Lowndes" <DavidL@example.invalid> wrote in message 
news:mt47g41cc57utcksj8qp6lo4ibfba3c56b@4ax.com...
> >Has anyone seen any info on how to associated a file type with my
>>dialog-based application?
>>
>>In order to use RegisterShellFileTypes(), I must add my document template
>>using AddDocTemplates(). But AddDocTemplates() can't be called without a
>>CDocument class.
>
> Jonathan,
>
> I think you just have to do it by adding the registry values manually
> (or through your application's setup program).
>
> See "File Types" in MSDN.
>
> Dave 

0
jwood (1292)
10/26/2008 7:53:20 PM
"Tom Serface" <tom.nospam@camaswood.com> wrote in message 
news:180CBCDD-725B-4E44-9D08-268B8A7E13B9@microsoft.com...

> One "modern" problem is that some users don't have access to this part of 
> the registry these days since it usually requires administrator 
> privileges. We've taken to adding these things in our setup programs 
> because those are typically run administrators anyway.  Even the main code 
> in MFC fails for many applications, you just don't see it because it fails 
> elegantly (just doesn't always work as expected).

I wasn't aware that the MFC code often fails. But these are exactly the 
types of concerns that were coming up when I thought about this.

> I think this may be better under Vista because I think the associations 
> there are under HKCU rather than HKCR.

So existing association-relationship is not compatible under Vista?

> If it were me, I'd just write a small routine to add the associations in 
> myself.
>
> Here's some code I use, but it hasn't been updated for Vista and assumes 
> administrator privileges for at least one running of my program:

Thanks. I'll have to look into the Vista issues further.

Oh, and what is Registry in the code below? Is that one of your own classes?

> void CMyApp::AddXXXRegistryType(void)
> {
>     Registry qdReg(HKEY_CLASSES_ROOT, _T(".xxx"),true,false);
>     Registry qdRegMyKey(HKEY_CLASSES_ROOT,_T("MyApp.MyKey"),true,false);
>     Registry 
> qdRegDefaultIcon(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\DefaultIcon"),true,false);
>     Registry 
> qdRegShellCommand(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\Shell\\Open\\Command"),true,false);
>     CString csProgramPath, csDefaultIcon, csCommand;
>     AfxGetModuleShortFileName(AfxGetInstanceHandle(), csProgramPath);
>     csDefaultIcon = csProgramPath + _T(",28"); // Index of icon in EXE
>     csCommand = csProgramPath + _T(" \"%1\"");
>
>     if (qdReg.IsValidKey()) {
>          bool bSuccess = qdReg.SetString(_T(""), _T("MyApp.MyKey"));
>          bSuccess = qdRegMyKey.SetString(_T(""),_T("MyApp.MyKey));
>          bSuccess = qdRegMyKey.SetInt(_T("EditFlags"),0);
>          bSuccess = qdRegDefaultIcon.SetString(_T(""),csDefaultIcon);
>          bSuccess = qdRegShellCommand.SetString(_T(""),csCommand);
>     }
>     else
>          LogEvent("HKEY_CLASSES_ROOT\\.xxx reg key not valid");
> }
>
> Tom
>
> "Jonathan Wood" <jwood@softcircuits.com> wrote in message 
> news:uBAcXjtNJHA.588@TK2MSFTNGP06.phx.gbl...
>> Has anyone seen any info on how to associated a file type with my 
>> dialog-based application?
>>
>> In order to use RegisterShellFileTypes(), I must add my document template 
>> using AddDocTemplates(). But AddDocTemplates() can't be called without a 
>> CDocument class.
>>
>> Thanks for any thoughts.
>>
>> -- 
>> Jonathan Wood
>> SoftCircuits Programming
>> http://www.softcircuits.com
>>
>

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
10/26/2008 7:57:37 PM
On Oct 25, 3:35=A0pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
> Has anyone seen any info on how to associated a file type with my
> dialog-based application?
>
> In order to use RegisterShellFileTypes(), I must add my document template
> using AddDocTemplates(). But AddDocTemplates() can't be called without a
> CDocument class.
>
> Thanks for any thoughts.
>
> --
> Jonathan Wood
> SoftCircuits Programminghttp://www.softcircuits.com

I dont have a good answer but cant you just take the code from source
that does the registration and use it in your app?

--
Ajay
0
ajaykalra (6842)
10/27/2008 6:27:07 PM
Yes, it's just a wrapper for the registry functionality.  I figured you 
could get the idea from the code...  The main thing is finding the right 
places in the registry to write the keys.

Tom

"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:ume%23aU6NJHA.4544@TK2MSFTNGP03.phx.gbl...
> "Tom Serface" <tom.nospam@camaswood.com> wrote in message 
> news:180CBCDD-725B-4E44-9D08-268B8A7E13B9@microsoft.com...
>
>> One "modern" problem is that some users don't have access to this part of 
>> the registry these days since it usually requires administrator 
>> privileges. We've taken to adding these things in our setup programs 
>> because those are typically run administrators anyway.  Even the main 
>> code in MFC fails for many applications, you just don't see it because it 
>> fails elegantly (just doesn't always work as expected).
>
> I wasn't aware that the MFC code often fails. But these are exactly the 
> types of concerns that were coming up when I thought about this.
>
>> I think this may be better under Vista because I think the associations 
>> there are under HKCU rather than HKCR.
>
> So existing association-relationship is not compatible under Vista?
>
>> If it were me, I'd just write a small routine to add the associations in 
>> myself.
>>
>> Here's some code I use, but it hasn't been updated for Vista and assumes 
>> administrator privileges for at least one running of my program:
>
> Thanks. I'll have to look into the Vista issues further.
>
> Oh, and what is Registry in the code below? Is that one of your own 
> classes?
>
>> void CMyApp::AddXXXRegistryType(void)
>> {
>>     Registry qdReg(HKEY_CLASSES_ROOT, _T(".xxx"),true,false);
>>     Registry qdRegMyKey(HKEY_CLASSES_ROOT,_T("MyApp.MyKey"),true,false);
>>     Registry 
>> qdRegDefaultIcon(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\DefaultIcon"),true,false);
>>     Registry 
>> qdRegShellCommand(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\Shell\\Open\\Command"),true,false);
>>     CString csProgramPath, csDefaultIcon, csCommand;
>>     AfxGetModuleShortFileName(AfxGetInstanceHandle(), csProgramPath);
>>     csDefaultIcon = csProgramPath + _T(",28"); // Index of icon in EXE
>>     csCommand = csProgramPath + _T(" \"%1\"");
>>
>>     if (qdReg.IsValidKey()) {
>>          bool bSuccess = qdReg.SetString(_T(""), _T("MyApp.MyKey"));
>>          bSuccess = qdRegMyKey.SetString(_T(""),_T("MyApp.MyKey));
>>          bSuccess = qdRegMyKey.SetInt(_T("EditFlags"),0);
>>          bSuccess = qdRegDefaultIcon.SetString(_T(""),csDefaultIcon);
>>          bSuccess = qdRegShellCommand.SetString(_T(""),csCommand);
>>     }
>>     else
>>          LogEvent("HKEY_CLASSES_ROOT\\.xxx reg key not valid");
>> }
>>
>> Tom
>>
>> "Jonathan Wood" <jwood@softcircuits.com> wrote in message 
>> news:uBAcXjtNJHA.588@TK2MSFTNGP06.phx.gbl...
>>> Has anyone seen any info on how to associated a file type with my 
>>> dialog-based application?
>>>
>>> In order to use RegisterShellFileTypes(), I must add my document 
>>> template using AddDocTemplates(). But AddDocTemplates() can't be called 
>>> without a CDocument class.
>>>
>>> Thanks for any thoughts.
>>>
>>> -- 
>>> Jonathan Wood
>>> SoftCircuits Programming
>>> http://www.softcircuits.com
>>>
>>
>
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 

0
tom.nospam (3240)
10/27/2008 9:02:17 PM
No, because it requires a document template, which requires a CDocument 
class, which my dialog-based application doesn't have.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
> Has anyone seen any info on how to associated a file type with my
> dialog-based application?
>
> In order to use RegisterShellFileTypes(), I must add my document template
> using AddDocTemplates(). But AddDocTemplates() can't be called without a
> CDocument class.
>
> Thanks for any thoughts.
>
> --
> Jonathan Wood
> SoftCircuits Programminghttp://www.softcircuits.com

I dont have a good answer but cant you just take the code from source
that does the registration and use it in your app?

--
Ajay 

0
jwood (1292)
10/27/2008 10:21:37 PM
Right. Thanks.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Tom Serface" <tom.nospam@camaswood.com> wrote in message 
news:487E2A3D-E676-4423-AF80-A1F8078091AA@microsoft.com...
> Yes, it's just a wrapper for the registry functionality.  I figured you 
> could get the idea from the code...  The main thing is finding the right 
> places in the registry to write the keys.
>
> Tom
>
> "Jonathan Wood" <jwood@softcircuits.com> wrote in message 
> news:ume%23aU6NJHA.4544@TK2MSFTNGP03.phx.gbl...
>> "Tom Serface" <tom.nospam@camaswood.com> wrote in message 
>> news:180CBCDD-725B-4E44-9D08-268B8A7E13B9@microsoft.com...
>>
>>> One "modern" problem is that some users don't have access to this part 
>>> of the registry these days since it usually requires administrator 
>>> privileges. We've taken to adding these things in our setup programs 
>>> because those are typically run administrators anyway.  Even the main 
>>> code in MFC fails for many applications, you just don't see it because 
>>> it fails elegantly (just doesn't always work as expected).
>>
>> I wasn't aware that the MFC code often fails. But these are exactly the 
>> types of concerns that were coming up when I thought about this.
>>
>>> I think this may be better under Vista because I think the associations 
>>> there are under HKCU rather than HKCR.
>>
>> So existing association-relationship is not compatible under Vista?
>>
>>> If it were me, I'd just write a small routine to add the associations in 
>>> myself.
>>>
>>> Here's some code I use, but it hasn't been updated for Vista and assumes 
>>> administrator privileges for at least one running of my program:
>>
>> Thanks. I'll have to look into the Vista issues further.
>>
>> Oh, and what is Registry in the code below? Is that one of your own 
>> classes?
>>
>>> void CMyApp::AddXXXRegistryType(void)
>>> {
>>>     Registry qdReg(HKEY_CLASSES_ROOT, _T(".xxx"),true,false);
>>>     Registry qdRegMyKey(HKEY_CLASSES_ROOT,_T("MyApp.MyKey"),true,false);
>>>     Registry 
>>> qdRegDefaultIcon(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\DefaultIcon"),true,false);
>>>     Registry 
>>> qdRegShellCommand(HKEY_CLASSES_ROOT,_T("MyApp.MyKey\\Shell\\Open\\Command"),true,false);
>>>     CString csProgramPath, csDefaultIcon, csCommand;
>>>     AfxGetModuleShortFileName(AfxGetInstanceHandle(), csProgramPath);
>>>     csDefaultIcon = csProgramPath + _T(",28"); // Index of icon in EXE
>>>     csCommand = csProgramPath + _T(" \"%1\"");
>>>
>>>     if (qdReg.IsValidKey()) {
>>>          bool bSuccess = qdReg.SetString(_T(""), _T("MyApp.MyKey"));
>>>          bSuccess = qdRegMyKey.SetString(_T(""),_T("MyApp.MyKey));
>>>          bSuccess = qdRegMyKey.SetInt(_T("EditFlags"),0);
>>>          bSuccess = qdRegDefaultIcon.SetString(_T(""),csDefaultIcon);
>>>          bSuccess = qdRegShellCommand.SetString(_T(""),csCommand);
>>>     }
>>>     else
>>>          LogEvent("HKEY_CLASSES_ROOT\\.xxx reg key not valid");
>>> }
>>>
>>> Tom
>>>
>>> "Jonathan Wood" <jwood@softcircuits.com> wrote in message 
>>> news:uBAcXjtNJHA.588@TK2MSFTNGP06.phx.gbl...
>>>> Has anyone seen any info on how to associated a file type with my 
>>>> dialog-based application?
>>>>
>>>> In order to use RegisterShellFileTypes(), I must add my document 
>>>> template using AddDocTemplates(). But AddDocTemplates() can't be called 
>>>> without a CDocument class.
>>>>
>>>> Thanks for any thoughts.
>>>>
>>>> -- 
>>>> Jonathan Wood
>>>> SoftCircuits Programming
>>>> http://www.softcircuits.com
>>>>
>>>
>>
>> -- 
>> Jonathan Wood
>> SoftCircuits Programming
>> http://www.softcircuits.com
>>
> 

0
jwood (1292)
10/27/2008 10:21:57 PM
No, go read the code.  It is in docmgr.cpp.  While the particular subroutine shown is a
class method of CDocManager, the code shows you what needs to be done (one of the
advantages of visible source).   So you *can* take the code from the source that does the
registration.

Generally, file associations are done in HKEY_CLASSES, which is normally protected.  This
is a major design failure in file associations; there SHOULD be a way for any given
logged-in user to have USER-SPECIFIC file bindings.  Fortunately, Vista handles this by
virtualizing the Registry (a feature which is said to be potentially unsupported in future
releases), but the real problem was the failure to think about per-user bindings.
					joe

On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>No, because it requires a document template, which requires a CDocument 
>class, which my dialog-based application doesn't have.
>
>-- 
>Jonathan Wood
>SoftCircuits Programming
>http://www.softcircuits.com
>
>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>> Has anyone seen any info on how to associated a file type with my
>> dialog-based application?
>>
>> In order to use RegisterShellFileTypes(), I must add my document template
>> using AddDocTemplates(). But AddDocTemplates() can't be called without a
>> CDocument class.
>>
>> Thanks for any thoughts.
>>
>> --
>> Jonathan Wood
>> SoftCircuits Programminghttp://www.softcircuits.com
>
>I dont have a good answer but cant you just take the code from source
>that does the registration and use it in your app?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/28/2008 2:46:23 AM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:kkucg4d9n2j4qu1lke6cqr8dgm2h68a0qv@4ax.com...

> No, go read the code.  It is in docmgr.cpp.  While the particular 
> subroutine shown is a
> class method of CDocManager, the code shows you what needs to be done (one 
> of the
> advantages of visible source).   So you *can* take the code from the 
> source that does the
> registration.

Well, the way "regular" apps do it is by calling RegisterShellFileTypes(). 
As the docs state, before calling this method, I must call AddDocTemplate(), 
which requires a reference to a CDocument class.

But, yes, I can study the MFC code to see how it is accomplished. I'm a bit 
surprised to hear it's in CDocManager since the method for this 
(RegisterShellFiletypes) is in  CWinApp.

But I'll take your advice and find it in the code and see what's involved.

> Generally, file associations are done in HKEY_CLASSES, which is normally 
> protected.  This
> is a major design failure in file associations; there SHOULD be a way for 
> any given
> logged-in user to have USER-SPECIFIC file bindings.  Fortunately, Vista 
> handles this by
> virtualizing the Registry (a feature which is said to be potentially 
> unsupported in future
> releases), but the real problem was the failure to think about per-user 
> bindings.

Yeah, there seems to be a mess of PITA issues in the name of security. Tom's 
suggestion of doing it in the Setup program makes a lot of sense.

Thanks.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
10/28/2008 5:12:20 AM
Joseph M. Newcomer wrote:
> No, go read the code.  It is in docmgr.cpp.  While the particular subroutine shown is a
> class method of CDocManager, the code shows you what needs to be done (one of the
> advantages of visible source).   So you *can* take the code from the source that does the
> registration.
> 
> Generally, file associations are done in HKEY_CLASSES, which is normally protected.  This
> is a major design failure in file associations; there SHOULD be a way for any given
> logged-in user to have USER-SPECIFIC file bindings.  Fortunately, Vista handles this by
> virtualizing the Registry (a feature which is said to be potentially unsupported in future
> releases), but the real problem was the failure to think about per-user bindings.

Joe:

IMHO, writing to HKEY_CLASSES_ROOT (HKCR), as the MFC code does, is always a 
mistake. The rule says that if the corresponding key is already present in HKCU, 
the write is done there, otherwise it is done in HKLM. In the latter case, the 
write will fail if the user does not have write permission in HKLM (it does not 
get transferred to HKCU). So writing to HKCR is a kind of crap-shoot, and 
consequently RegisterShellFileTypes() is broken.

So my opinion is:

1. Setup programs should write to HKLM

2. Applications (including MFC code) should write to HKCU.

[Actually, this is the correct strategy for registry-writing in general, but it 
is also true for the sections that correspond to HKCR.]

Vista virtualization is not the solution, I think. In fact an application 
intended for Vista should have a manifest section that prevents virtualization.

Another issue is that the traditional file association settings in HKCR are 
overruled by the per-user "Open With" settings, which are stored elsewhere in 
the HKCU registry.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
10/28/2008 11:15:10 AM
Of course, there is a simpler answer: if you don't have one, create one!

CSingleDocTemplate templ = new CSingleDocTemplate(
					IDR_WHATEVER,
					RUNTIME_CLASS(CSomeView),
					RUNTIME_CLASS(CChildFrame),
					RUNTIME_CLASS(CSomeDocument));
templ->RegisterShellFileTypes();
delete templ;

So you create a dummy view, frame, and document which you can copy from a simple dummy app
"Some" that you create.  Since you will never instantiate these classes, they are harmless
(and don't whine about "They take up code space" since code space is utterly and
completely irrelevant to Windows application programming).  Create a dummy app, do a
little creative copy-and-paste (don't forget the IDR_WHATEVER string and icon!) and you're
done.
				joe

On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>No, because it requires a document template, which requires a CDocument 
>class, which my dialog-based application doesn't have.
>
>-- 
>Jonathan Wood
>SoftCircuits Programming
>http://www.softcircuits.com
>
>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>> Has anyone seen any info on how to associated a file type with my
>> dialog-based application?
>>
>> In order to use RegisterShellFileTypes(), I must add my document template
>> using AddDocTemplates(). But AddDocTemplates() can't be called without a
>> CDocument class.
>>
>> Thanks for any thoughts.
>>
>> --
>> Jonathan Wood
>> SoftCircuits Programminghttp://www.softcircuits.com
>
>I dont have a good answer but cant you just take the code from source
>that does the registration and use it in your app?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/28/2008 11:56:51 AM
See the post I just made.  So what?  You don't need to AddDocTemplate if you call the
method of the document template...

Why not in CDocManager?  After all, it is a method of a document manager...
				joe

On Mon, 27 Oct 2008 23:12:20 -0600, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:kkucg4d9n2j4qu1lke6cqr8dgm2h68a0qv@4ax.com...
>
>> No, go read the code.  It is in docmgr.cpp.  While the particular 
>> subroutine shown is a
>> class method of CDocManager, the code shows you what needs to be done (one 
>> of the
>> advantages of visible source).   So you *can* take the code from the 
>> source that does the
>> registration.
>
>Well, the way "regular" apps do it is by calling RegisterShellFileTypes(). 
>As the docs state, before calling this method, I must call AddDocTemplate(), 
>which requires a reference to a CDocument class.
>
>But, yes, I can study the MFC code to see how it is accomplished. I'm a bit 
>surprised to hear it's in CDocManager since the method for this 
>(RegisterShellFiletypes) is in  CWinApp.
>
>But I'll take your advice and find it in the code and see what's involved.
>
>> Generally, file associations are done in HKEY_CLASSES, which is normally 
>> protected.  This
>> is a major design failure in file associations; there SHOULD be a way for 
>> any given
>> logged-in user to have USER-SPECIFIC file bindings.  Fortunately, Vista 
>> handles this by
>> virtualizing the Registry (a feature which is said to be potentially 
>> unsupported in future
>> releases), but the real problem was the failure to think about per-user 
>> bindings.
>
>Yeah, there seems to be a mess of PITA issues in the name of security. Tom's 
>suggestion of doing it in the Setup program makes a lot of sense.
>
>Thanks.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/28/2008 11:58:43 AM
See below...
On Tue, 28 Oct 2008 07:15:10 -0400, David Wilkinson <no-reply@effisols.com> wrote:

>Joseph M. Newcomer wrote:
>> No, go read the code.  It is in docmgr.cpp.  While the particular subroutine shown is a
>> class method of CDocManager, the code shows you what needs to be done (one of the
>> advantages of visible source).   So you *can* take the code from the source that does the
>> registration.
>> 
>> Generally, file associations are done in HKEY_CLASSES, which is normally protected.  This
>> is a major design failure in file associations; there SHOULD be a way for any given
>> logged-in user to have USER-SPECIFIC file bindings.  Fortunately, Vista handles this by
>> virtualizing the Registry (a feature which is said to be potentially unsupported in future
>> releases), but the real problem was the failure to think about per-user bindings.
>
>Joe:
>
>IMHO, writing to HKEY_CLASSES_ROOT (HKCR), as the MFC code does, is always a 
>mistake. The rule says that if the corresponding key is already present in HKCU, 
>the write is done there, otherwise it is done in HKLM. In the latter case, the 
>write will fail if the user does not have write permission in HKLM (it does not 
>get transferred to HKCU). So writing to HKCR is a kind of crap-shoot, and 
>consequently RegisterShellFileTypes() is broken.
****
So much of this code dates back to Win16 when the computer had but a single user.  It is
sad, really, that the overall attitude at Microsoft still are stuck in the late 1980s, and
here we are, 20 years later, with the same design errors in Windows and in the code.

I agree completely: it is broken.
****
>
>So my opinion is:
>
>1. Setup programs should write to HKLM
>
>2. Applications (including MFC code) should write to HKCU.
>
>[Actually, this is the correct strategy for registry-writing in general, but it 
>is also true for the sections that correspond to HKCR.]
>
>Vista virtualization is not the solution, I think. In fact an application 
>intended for Vista should have a manifest section that prevents virtualization.
>
>Another issue is that the traditional file association settings in HKCR are 
>overruled by the per-user "Open With" settings, which are stored elsewhere in 
>the HKCU registry.
****
Pile enough afterthoughts on and you have the illusion the code works.
				joe
****
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/28/2008 12:01:26 PM
Joseph M. Newcomer wrote:
> So much of this code dates back to Win16 when the computer had but a single user.  It is
> sad, really, that the overall attitude at Microsoft still are stuck in the late 1980s, and
> here we are, 20 years later, with the same design errors in Windows and in the code.
> 
> I agree completely: it is broken.

Joe:

Yes, in fact RegisterShellFileTypes() has always been broken for a standard user 
on NT-based systems, because they cannot write to HKLM. On Vista it is broken 
for Administrators also, unless the application does not have a Vista-aware 
manifest.

THe MFC code could be simply fixed by having it write to 
HKEY_CURRENT_USER\Software\Classes rather than to HKCR.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
10/28/2008 1:24:47 PM
Yes, fortunately it breaks silently, but the user doesn't always get the 
Explorer interaction they think they will.  I typically tell my users just 
to run once as administrator or install as admin and that sets up the keys 
and the subsequent times are just ignored.  It's probably Windows that is 
making the assumption as much as MFC.

Tom

"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:Or$Jx5OOJHA.1896@TK2MSFTNGP02.phx.gbl...

> IMHO, writing to HKEY_CLASSES_ROOT (HKCR), as the MFC code does, is always 
> a mistake. The rule says that if the corresponding key is already present 
> in HKCU, the write is done there, otherwise it is done in HKLM. In the 
> latter case, the write will fail if the user does not have write 
> permission in HKLM (it does not get transferred to HKCU). So writing to 
> HKCR is a kind of crap-shoot, and consequently RegisterShellFileTypes() is 
> broken.
>
> So my opinion is:
>
> 1. Setup programs should write to HKLM
>
> 2. Applications (including MFC code) should write to HKCU.
>
> [Actually, this is the correct strategy for registry-writing in general, 
> but it is also true for the sections that correspond to HKCR.]
>
> Vista virtualization is not the solution, I think. In fact an application 
> intended for Vista should have a manifest section that prevents 
> virtualization.
>
> Another issue is that the traditional file association settings in HKCR 
> are overruled by the per-user "Open With" settings, which are stored 
> elsewhere in the HKCU registry.
>
> -- 
> David Wilkinson
> Visual C++ MVP 

0
tom.nospam (3240)
10/28/2008 1:45:08 PM
Maybe they will fix this in the next release of MFC?  Seems like an easy fix 
to implement and certainly would fix a previous breaking change so seems 
logical.

Tom

"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:eoXIMCQOJHA.4092@TK2MSFTNGP06.phx.gbl...
> Joseph M. Newcomer wrote:
>> So much of this code dates back to Win16 when the computer had but a 
>> single user.  It is
>> sad, really, that the overall attitude at Microsoft still are stuck in 
>> the late 1980s, and
>> here we are, 20 years later, with the same design errors in Windows and 
>> in the code.
>>
>> I agree completely: it is broken.
>
> Joe:
>
> Yes, in fact RegisterShellFileTypes() has always been broken for a 
> standard user on NT-based systems, because they cannot write to HKLM. On 
> Vista it is broken for Administrators also, unless the application does 
> not have a Vista-aware manifest.
>
> THe MFC code could be simply fixed by having it write to 
> HKEY_CURRENT_USER\Software\Classes rather than to HKCR.
>
> -- 
> David Wilkinson
> Visual C++ MVP 

0
tom.nospam (3240)
10/28/2008 1:46:06 PM
That seems like a lot of work to go through to get to a function that 
doesn't work reliably anyway :o)

If it were me I'd just write to the proper place.  Especially if I didn't 
need any of the other shell processing stuff (like switches or opening 
documents at run time).

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
> Of course, there is a simpler answer: if you don't have one, create one!
>
> CSingleDocTemplate templ = new CSingleDocTemplate(
> IDR_WHATEVER,
> RUNTIME_CLASS(CSomeView),
> RUNTIME_CLASS(CChildFrame),
> RUNTIME_CLASS(CSomeDocument));
> templ->RegisterShellFileTypes();
> delete templ;
>
> So you create a dummy view, frame, and document which you can copy from a 
> simple dummy app
> "Some" that you create.  Since you will never instantiate these classes, 
> they are harmless
> (and don't whine about "They take up code space" since code space is 
> utterly and
> completely irrelevant to Windows application programming).  Create a dummy 
> app, do a
> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
> icon!) and you're
> done.
> joe
>
> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
> <jwood@softcircuits.com> wrote:
>
>>No, because it requires a document template, which requires a CDocument
>>class, which my dialog-based application doesn't have.
>>
>>-- 
>>Jonathan Wood
>>SoftCircuits Programming
>>http://www.softcircuits.com
>>
>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>> Has anyone seen any info on how to associated a file type with my
>>> dialog-based application?
>>>
>>> In order to use RegisterShellFileTypes(), I must add my document 
>>> template
>>> using AddDocTemplates(). But AddDocTemplates() can't be called without a
>>> CDocument class.
>>>
>>> Thanks for any thoughts.
>>>
>>> --
>>> Jonathan Wood
>>> SoftCircuits Programminghttp://www.softcircuits.com
>>
>>I dont have a good answer but cant you just take the code from source
>>that does the registration and use it in your app?
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
tom.nospam (3240)
10/28/2008 1:47:10 PM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
> Of course, there is a simpler answer: if you don't have one, create one!
>
> CSingleDocTemplate templ = new CSingleDocTemplate(
> IDR_WHATEVER,
> RUNTIME_CLASS(CSomeView),
> RUNTIME_CLASS(CChildFrame),
> RUNTIME_CLASS(CSomeDocument));
> templ->RegisterShellFileTypes();
> delete templ;
>
> So you create a dummy view, frame, and document which you can copy from a 
> simple dummy app
> "Some" that you create.  Since you will never instantiate these classes, 
> they are harmless
> (and don't whine about "They take up code space" since code space is 
> utterly and
> completely irrelevant to Windows application programming).  Create a dummy 
> app, do a
> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
> icon!) and you're
> done.

I would not recommend obfuscating a simple matter of adding well documented 
registry keys with doing this.  Not only is it obscure, but also requires 
you to create CSomeView, CChildFrame, and CSomeDocument classes, for the 
sole purpose of doing this!  Not only that you need to also add an obscure 
IDR_MAINFRAME (I think it is) string in the stringtable that has newline 
delimited fields, a few of which pertain to defining what file extensions 
you are interested in overriding.

-- David 

0
dc2983 (3206)
10/28/2008 2:13:54 PM
"Tom Serface" <tom.nospam@camaswood.com> wrote in message 
news:B9831AF5-2A24-49FA-8F13-E83E27B1FEC7@microsoft.com...
> That seems like a lot of work to go through to get to a function that 
> doesn't work reliably anyway :o)

Heh, that's just what I was thinking.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


> If it were me I'd just write to the proper place.  Especially if I didn't 
> need any of the other shell processing stuff (like switches or opening 
> documents at run time).
>
> Tom
>
> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
> news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
>> Of course, there is a simpler answer: if you don't have one, create one!
>>
>> CSingleDocTemplate templ = new CSingleDocTemplate(
>> IDR_WHATEVER,
>> RUNTIME_CLASS(CSomeView),
>> RUNTIME_CLASS(CChildFrame),
>> RUNTIME_CLASS(CSomeDocument));
>> templ->RegisterShellFileTypes();
>> delete templ;
>>
>> So you create a dummy view, frame, and document which you can copy from a 
>> simple dummy app
>> "Some" that you create.  Since you will never instantiate these classes, 
>> they are harmless
>> (and don't whine about "They take up code space" since code space is 
>> utterly and
>> completely irrelevant to Windows application programming).  Create a 
>> dummy app, do a
>> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
>> icon!) and you're
>> done.
>> joe
>>
>> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
>> <jwood@softcircuits.com> wrote:
>>
>>>No, because it requires a document template, which requires a CDocument
>>>class, which my dialog-based application doesn't have.
>>>
>>>-- 
>>>Jonathan Wood
>>>SoftCircuits Programming
>>>http://www.softcircuits.com
>>>
>>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>>> Has anyone seen any info on how to associated a file type with my
>>>> dialog-based application?
>>>>
>>>> In order to use RegisterShellFileTypes(), I must add my document 
>>>> template
>>>> using AddDocTemplates(). But AddDocTemplates() can't be called without 
>>>> a
>>>> CDocument class.
>>>>
>>>> Thanks for any thoughts.
>>>>
>>>> --
>>>> Jonathan Wood
>>>> SoftCircuits Programminghttp://www.softcircuits.com
>>>
>>>I dont have a good answer but cant you just take the code from source
>>>that does the registration and use it in your app?
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 

0
jwood (1292)
10/28/2008 2:26:59 PM
The whining about code space would primarily relate to code readability and 
maintainability. And, yes, I consider these real issues.

At any rate, since it seems everyone agrees the code doesn't work, there 
doesn't appear to be a whole lot of incentive for such an approach.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
> Of course, there is a simpler answer: if you don't have one, create one!
>
> CSingleDocTemplate templ = new CSingleDocTemplate(
> IDR_WHATEVER,
> RUNTIME_CLASS(CSomeView),
> RUNTIME_CLASS(CChildFrame),
> RUNTIME_CLASS(CSomeDocument));
> templ->RegisterShellFileTypes();
> delete templ;
>
> So you create a dummy view, frame, and document which you can copy from a 
> simple dummy app
> "Some" that you create.  Since you will never instantiate these classes, 
> they are harmless
> (and don't whine about "They take up code space" since code space is 
> utterly and
> completely irrelevant to Windows application programming).  Create a dummy 
> app, do a
> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
> icon!) and you're
> done.
> joe
>
> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
> <jwood@softcircuits.com> wrote:
>
>>No, because it requires a document template, which requires a CDocument
>>class, which my dialog-based application doesn't have.
>>
>>-- 
>>Jonathan Wood
>>SoftCircuits Programming
>>http://www.softcircuits.com
>>
>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>> Has anyone seen any info on how to associated a file type with my
>>> dialog-based application?
>>>
>>> In order to use RegisterShellFileTypes(), I must add my document 
>>> template
>>> using AddDocTemplates(). But AddDocTemplates() can't be called without a
>>> CDocument class.
>>>
>>> Thanks for any thoughts.
>>>
>>> --
>>> Jonathan Wood
>>> SoftCircuits Programminghttp://www.softcircuits.com
>>
>>I dont have a good answer but cant you just take the code from source
>>that does the registration and use it in your app?
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
jwood (1292)
10/28/2008 2:28:39 PM
>Maybe they will fix this in the next release of MFC?  Seems like an easy fix 
>to implement and certainly would fix a previous breaking change so seems 
>logical.

Tom,

I suggest that you submit a bug report on Connect then. As far as I
can see, it's still using HKEY_CLASSES_ROOT in the CTP release.

Dave
0
davidl7375 (2060)
10/28/2008 2:42:16 PM
Good idea and will do...

Tom

"David Lowndes" <DavidL@example.invalid> wrote in message 
news:749eg4tpprar2tj8958v32vn26jc9tu00u@4ax.com...
> >Maybe they will fix this in the next release of MFC?  Seems like an easy 
> >fix
>>to implement and certainly would fix a previous breaking change so seems
>>logical.
>
> Tom,
>
> I suggest that you submit a bug report on Connect then. As far as I
> can see, it's still using HKEY_CLASSES_ROOT in the CTP release.
>
> Dave 

0
tom.nospam (3240)
10/28/2008 3:04:41 PM
It's unfair to say "doesn't work".  It works if all of the conditions are 
right and the user is logged in as an administrator.

You're right that this code makes the "purpose" a little unclear.  I know 
that Joe is a huge proponent of code readability and maintainability so he 
probably was just offering up a suggestion that he may not actually 
implement himself.  I have a really intelligent friend who always answers 
questions matter of fact even if the answer borders on ridiculous so I have 
learned to always phrase my questions very carefully.  Fortunately, it's 
worth the risk since he knows so much I need to find out about.
:o)

Tom

"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:eGJf8lQOJHA.728@TK2MSFTNGP06.phx.gbl...
> The whining about code space would primarily relate to code readability 
> and maintainability. And, yes, I consider these real issues.
>
> At any rate, since it seems everyone agrees the code doesn't work, there 
> doesn't appear to be a whole lot of incentive for such an approach.
>
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
>
> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
> news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
>> Of course, there is a simpler answer: if you don't have one, create one!
>>
>> CSingleDocTemplate templ = new CSingleDocTemplate(
>> IDR_WHATEVER,
>> RUNTIME_CLASS(CSomeView),
>> RUNTIME_CLASS(CChildFrame),
>> RUNTIME_CLASS(CSomeDocument));
>> templ->RegisterShellFileTypes();
>> delete templ;
>>
>> So you create a dummy view, frame, and document which you can copy from a 
>> simple dummy app
>> "Some" that you create.  Since you will never instantiate these classes, 
>> they are harmless
>> (and don't whine about "They take up code space" since code space is 
>> utterly and
>> completely irrelevant to Windows application programming).  Create a 
>> dummy app, do a
>> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
>> icon!) and you're
>> done.
>> joe
>>
>> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
>> <jwood@softcircuits.com> wrote:
>>
>>>No, because it requires a document template, which requires a CDocument
>>>class, which my dialog-based application doesn't have.
>>>
>>>-- 
>>>Jonathan Wood
>>>SoftCircuits Programming
>>>http://www.softcircuits.com
>>>
>>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>>> Has anyone seen any info on how to associated a file type with my
>>>> dialog-based application?
>>>>
>>>> In order to use RegisterShellFileTypes(), I must add my document 
>>>> template
>>>> using AddDocTemplates(). But AddDocTemplates() can't be called without 
>>>> a
>>>> CDocument class.
>>>>
>>>> Thanks for any thoughts.
>>>>
>>>> --
>>>> Jonathan Wood
>>>> SoftCircuits Programminghttp://www.softcircuits.com
>>>
>>>I dont have a good answer but cant you just take the code from source
>>>that does the registration and use it in your app?
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 

0
tom.nospam (3240)
10/28/2008 3:10:38 PM
Tom,

> It's unfair to say "doesn't work".  It works if all of the conditions are 
> right and the user is logged in as an administrator.

You know..., there are folks looking to write reliable code. Such folks do 
not consider code that fails more often than it works as "working." I think 
it would be safe to put me in this category.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

0
jwood (1292)
10/28/2008 3:27:27 PM
On Oct 28, 1:12=A0am, "Jonathan Wood" <jw...@softcircuits.com> wrote:

> Yeah, there seems to be a mess of PITA issues in the name of security. To=
m's
> suggestion of doing it in the Setup program makes a lot of sense.

For what its worth, we did it in the app itself and it worked fine for
us. It would register components/doc settings when you ran the app the
first time. Setup registration might work better as the unistallation
can also unregister the doc settings.

--
Ajay
0
ajaykalra (6842)
10/28/2008 6:00:25 PM
Ajay Kalra wrote:
> For what its worth, we did it in the app itself and it worked fine for
> us. It would register components/doc settings when you ran the app the
> first time. Setup registration might work better as the unistallation
> can also unregister the doc settings.

Ajay:

I guess your users must have been administrators...

You are correct that another problem with RegisterShellFileTypes() is that it 
does not get reversed when the app is uninstalled.

-- 
David Wilkinson
Visual C++ MVP
0
no-reply8010 (1791)
10/28/2008 6:42:48 PM
Just to clarify, did you make the change to HKCU? Or did you have all your 
customers run as administrators?

If you have an expensive, custom program with a dozen or so customers, then 
having them run the software as administrators is feasible. But if you are 
mass-distributing a low-cost app, it isn't.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
news:113ea482-f4af-4b6b-b80a-b991298a908f@v13g2000pro.googlegroups.com...
On Oct 28, 1:12 am, "Jonathan Wood" <jw...@softcircuits.com> wrote:

> Yeah, there seems to be a mess of PITA issues in the name of security. 
> Tom's
> suggestion of doing it in the Setup program makes a lot of sense.

For what its worth, we did it in the app itself and it worked fine for
us. It would register components/doc settings when you ran the app the
first time. Setup registration might work better as the unistallation
can also unregister the doc settings.

--
Ajay 

0
jwood (1292)
10/28/2008 7:40:26 PM
I had a client earlier this year that was distributing an app which could only run correct
in Vista "as administrator".  The problem was that they are a mass-distribution app, and
Microsoft will apparently not logo any program that requires admin privileges to run.  I
spent 3 weeks learning a lot about a very narrow piece of Vista security, and 3 weeks
incorporating that knowledge into the program so that it could run without admin
privileges, and it was *not* an easy conversion at all!  So this suggests that a
mass-distributed app won't receive logo certification if it requires admin, which could be
a marketing disaster.
				joe

On Tue, 28 Oct 2008 13:40:26 -0600, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>Just to clarify, did you make the change to HKCU? Or did you have all your 
>customers run as administrators?
>
>If you have an expensive, custom program with a dozen or so customers, then 
>having them run the software as administrators is feasible. But if you are 
>mass-distributing a low-cost app, it isn't.
>
>-- 
>Jonathan Wood
>SoftCircuits Programming
>http://www.softcircuits.com
>
>
>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message 
>news:113ea482-f4af-4b6b-b80a-b991298a908f@v13g2000pro.googlegroups.com...
>On Oct 28, 1:12 am, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>
>> Yeah, there seems to be a mess of PITA issues in the name of security. 
>> Tom's
>> suggestion of doing it in the Setup program makes a lot of sense.
>
>For what its worth, we did it in the app itself and it worked fine for
>us. It would register components/doc settings when you ran the app the
>first time. Setup registration might work better as the unistallation
>can also unregister the doc settings.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/29/2008 12:28:19 AM
Yes, I was assuming that full shell functionality was desired.

I wrote about self-registering apps some time ago, including the ability to register the
MESSAGETABLE information for the event viewer.  But as mentioned, I tell the programmers
now that this should be done as part of the install, rather than as code in the program,
because of the security considerations.
				joe

On Tue, 28 Oct 2008 06:47:10 -0700, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>That seems like a lot of work to go through to get to a function that 
>doesn't work reliably anyway :o)
>
>If it were me I'd just write to the proper place.  Especially if I didn't 
>need any of the other shell processing stuff (like switches or opening 
>documents at run time).
>
>Tom
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
>> Of course, there is a simpler answer: if you don't have one, create one!
>>
>> CSingleDocTemplate templ = new CSingleDocTemplate(
>> IDR_WHATEVER,
>> RUNTIME_CLASS(CSomeView),
>> RUNTIME_CLASS(CChildFrame),
>> RUNTIME_CLASS(CSomeDocument));
>> templ->RegisterShellFileTypes();
>> delete templ;
>>
>> So you create a dummy view, frame, and document which you can copy from a 
>> simple dummy app
>> "Some" that you create.  Since you will never instantiate these classes, 
>> they are harmless
>> (and don't whine about "They take up code space" since code space is 
>> utterly and
>> completely irrelevant to Windows application programming).  Create a dummy 
>> app, do a
>> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
>> icon!) and you're
>> done.
>> joe
>>
>> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
>> <jwood@softcircuits.com> wrote:
>>
>>>No, because it requires a document template, which requires a CDocument
>>>class, which my dialog-based application doesn't have.
>>>
>>>-- 
>>>Jonathan Wood
>>>SoftCircuits Programming
>>>http://www.softcircuits.com
>>>
>>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>>> Has anyone seen any info on how to associated a file type with my
>>>> dialog-based application?
>>>>
>>>> In order to use RegisterShellFileTypes(), I must add my document 
>>>> template
>>>> using AddDocTemplates(). But AddDocTemplates() can't be called without a
>>>> CDocument class.
>>>>
>>>> Thanks for any thoughts.
>>>>
>>>> --
>>>> Jonathan Wood
>>>> SoftCircuits Programminghttp://www.softcircuits.com
>>>
>>>I dont have a good answer but cant you just take the code from source
>>>that does the registration and use it in your app?
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/29/2008 12:31:09 AM
The point is, the complaint was that the only way to use the built-in registration was to
use a document template, "which I don't have".  One way around this is to have one.  I
didn't say it was a *good* solution, just an easy one.
					joe

On Tue, 28 Oct 2008 07:13:54 -0700, "David Ching" <dc@remove-this.dcsoft.com> wrote:

>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
>> Of course, there is a simpler answer: if you don't have one, create one!
>>
>> CSingleDocTemplate templ = new CSingleDocTemplate(
>> IDR_WHATEVER,
>> RUNTIME_CLASS(CSomeView),
>> RUNTIME_CLASS(CChildFrame),
>> RUNTIME_CLASS(CSomeDocument));
>> templ->RegisterShellFileTypes();
>> delete templ;
>>
>> So you create a dummy view, frame, and document which you can copy from a 
>> simple dummy app
>> "Some" that you create.  Since you will never instantiate these classes, 
>> they are harmless
>> (and don't whine about "They take up code space" since code space is 
>> utterly and
>> completely irrelevant to Windows application programming).  Create a dummy 
>> app, do a
>> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
>> icon!) and you're
>> done.
>
>I would not recommend obfuscating a simple matter of adding well documented 
>registry keys with doing this.  Not only is it obscure, but also requires 
>you to create CSomeView, CChildFrame, and CSomeDocument classes, for the 
>sole purpose of doing this!  Not only that you need to also add an obscure 
>IDR_MAINFRAME (I think it is) string in the stringtable that has newline 
>delimited fields, a few of which pertain to defining what file extensions 
>you are interested in overriding.
>
>-- David 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/29/2008 12:32:24 AM
I'd use my Registry library because it is so trivial to use and I don't have to think
about the problems.  
				joe

On Tue, 28 Oct 2008 08:10:38 -0700, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>It's unfair to say "doesn't work".  It works if all of the conditions are 
>right and the user is logged in as an administrator.
>
>You're right that this code makes the "purpose" a little unclear.  I know 
>that Joe is a huge proponent of code readability and maintainability so he 
>probably was just offering up a suggestion that he may not actually 
>implement himself.  I have a really intelligent friend who always answers 
>questions matter of fact even if the answer borders on ridiculous so I have 
>learned to always phrase my questions very carefully.  Fortunately, it's 
>worth the risk since he knows so much I need to find out about.
>:o)
>
>Tom
>
>"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
>news:eGJf8lQOJHA.728@TK2MSFTNGP06.phx.gbl...
>> The whining about code space would primarily relate to code readability 
>> and maintainability. And, yes, I consider these real issues.
>>
>> At any rate, since it seems everyone agrees the code doesn't work, there 
>> doesn't appear to be a whole lot of incentive for such an approach.
>>
>> -- 
>> Jonathan Wood
>> SoftCircuits Programming
>> http://www.softcircuits.com
>>
>> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>> news:97vdg41tm8jo4b84ivpditikve0prierql@4ax.com...
>>> Of course, there is a simpler answer: if you don't have one, create one!
>>>
>>> CSingleDocTemplate templ = new CSingleDocTemplate(
>>> IDR_WHATEVER,
>>> RUNTIME_CLASS(CSomeView),
>>> RUNTIME_CLASS(CChildFrame),
>>> RUNTIME_CLASS(CSomeDocument));
>>> templ->RegisterShellFileTypes();
>>> delete templ;
>>>
>>> So you create a dummy view, frame, and document which you can copy from a 
>>> simple dummy app
>>> "Some" that you create.  Since you will never instantiate these classes, 
>>> they are harmless
>>> (and don't whine about "They take up code space" since code space is 
>>> utterly and
>>> completely irrelevant to Windows application programming).  Create a 
>>> dummy app, do a
>>> little creative copy-and-paste (don't forget the IDR_WHATEVER string and 
>>> icon!) and you're
>>> done.
>>> joe
>>>
>>> On Mon, 27 Oct 2008 16:21:37 -0600, "Jonathan Wood" 
>>> <jwood@softcircuits.com> wrote:
>>>
>>>>No, because it requires a document template, which requires a CDocument
>>>>class, which my dialog-based application doesn't have.
>>>>
>>>>-- 
>>>>Jonathan Wood
>>>>SoftCircuits Programming
>>>>http://www.softcircuits.com
>>>>
>>>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>>>news:1af5bb74-a7cd-424b-9bd0-f2672a1d96ac@t54g2000hsg.googlegroups.com...
>>>>On Oct 25, 3:35 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>>>> Has anyone seen any info on how to associated a file type with my
>>>>> dialog-based application?
>>>>>
>>>>> In order to use RegisterShellFileTypes(), I must add my document 
>>>>> template
>>>>> using AddDocTemplates(). But AddDocTemplates() can't be called without 
>>>>> a
>>>>> CDocument class.
>>>>>
>>>>> Thanks for any thoughts.
>>>>>
>>>>> --
>>>>> Jonathan Wood
>>>>> SoftCircuits Programminghttp://www.softcircuits.com
>>>>
>>>>I dont have a good answer but cant you just take the code from source
>>>>that does the registration and use it in your app?
>>> Joseph M. Newcomer [MVP]
>>> email: newcomer@flounder.com
>>> Web: http://www.flounder.com
>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/29/2008 12:33:18 AM
That's not the biggest issue in my view. If you've ever mass distributed a 
simple app, then you know what type of customers you run into from time to 
time. Having to explain to these people how and why they must run in admin 
mode? I don't think so.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:vbbfg41isse86ib94dkgqnirltejhkofj8@4ax.com...
>I had a client earlier this year that was distributing an app which could 
>only run correct
> in Vista "as administrator".  The problem was that they are a 
> mass-distribution app, and
> Microsoft will apparently not logo any program that requires admin 
> privileges to run.  I
> spent 3 weeks learning a lot about a very narrow piece of Vista security, 
> and 3 weeks
> incorporating that knowledge into the program so that it could run without 
> admin
> privileges, and it was *not* an easy conversion at all!  So this suggests 
> that a
> mass-distributed app won't receive logo certification if it requires 
> admin, which could be
> a marketing disaster.
> joe
>
> On Tue, 28 Oct 2008 13:40:26 -0600, "Jonathan Wood" 
> <jwood@softcircuits.com> wrote:
>
>>Just to clarify, did you make the change to HKCU? Or did you have all your
>>customers run as administrators?
>>
>>If you have an expensive, custom program with a dozen or so customers, 
>>then
>>having them run the software as administrators is feasible. But if you are
>>mass-distributing a low-cost app, it isn't.
>>
>>-- 
>>Jonathan Wood
>>SoftCircuits Programming
>>http://www.softcircuits.com
>>
>>
>>"Ajay Kalra" <ajaykalra@yahoo.com> wrote in message
>>news:113ea482-f4af-4b6b-b80a-b991298a908f@v13g2000pro.googlegroups.com...
>>On Oct 28, 1:12 am, "Jonathan Wood" <jw...@softcircuits.com> wrote:
>>
>>> Yeah, there seems to be a mess of PITA issues in the name of security.
>>> Tom's
>>> suggestion of doing it in the Setup program makes a lot of sense.
>>
>>For what its worth, we did it in the app itself and it worked fine for
>>us. It would register components/doc settings when you ran the app the
>>first time. Setup registration might work better as the unistallation
>>can also unregister the doc settings.
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
jwood (1292)
10/29/2008 12:40:25 AM
"Fail" is a strange metric in some cases.

For example, I once worked in a system where I created about 50 resource elements (one per
file, each not more than 32K, the Win16 limitation).  I gave them integer IDs, 1..n (n was
between 47 and 54 depending on the data).  My client complained that my code was
"defective" because, when he ran it under Bounds Checker for Windows, FindResouce would
"fail", and this was clearly a bug in the program.  Of course, it was 
	HRSRC rsrc = ::FindResource(hlib, 
				      MAKEINTRESOURCE(n),
 MAKEINTRESOURCE(MY_RESOURCE_TYPE));
so OF COURSE it would fail when there were no more resources found in that library!  It
was *supposed* to fail!  So it was hard to understand why he was upset that the API would
fail.  He also complained that ::LoadLibrary kept failing.  The DLLs had names like
DATA00.DLL, DATA01.DLL, ... so I just formed the name by adding 1 to a counter and
generating the next DLL name and opening it, then iterating through its resources, and so
on.  So when I ran out of DLLs, I knew I had come to the end of the available DLLs.  

If an update had fewer DLLs, I could then use the VERSIONINFO information and older DLLs
that were higher-numbered than the version of DATA00.DLL would be deleted.

So if the rule is that it succeeds as admin and fails silently without admin, is it really
"failure"?  

The real problem is the erroneous assumption that there can only be one users per machine,
and the failures that accompany that flawed assumption.
					joe

On Tue, 28 Oct 2008 09:27:27 -0600, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>Tom,
>
>> It's unfair to say "doesn't work".  It works if all of the conditions are 
>> right and the user is logged in as an administrator.
>
>You know..., there are folks looking to write reliable code. Such folks do 
>not consider code that fails more often than it works as "working." I think 
>it would be safe to put me in this category.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/29/2008 12:43:04 AM
Whether or not some arbitrary check of the program finds an issue is one 
thing. A routine to associate a file type with a program that does not 
associate a file type with that program, I'd go out on a limb and say that 
would have failed. Afterall, it failed to associate the file type with the 
program.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:tqbfg4d56k4m8jldbeooek86emdbndtaoq@4ax.com...
> "Fail" is a strange metric in some cases.
>
> For example, I once worked in a system where I created about 50 resource 
> elements (one per
> file, each not more than 32K, the Win16 limitation).  I gave them integer 
> IDs, 1..n (n was
> between 47 and 54 depending on the data).  My client complained that my 
> code was
> "defective" because, when he ran it under Bounds Checker for Windows, 
> FindResouce would
> "fail", and this was clearly a bug in the program.  Of course, it was
> HRSRC rsrc = ::FindResource(hlib,
>       MAKEINTRESOURCE(n),
> MAKEINTRESOURCE(MY_RESOURCE_TYPE));
> so OF COURSE it would fail when there were no more resources found in that 
> library!  It
> was *supposed* to fail!  So it was hard to understand why he was upset 
> that the API would
> fail.  He also complained that ::LoadLibrary kept failing.  The DLLs had 
> names like
> DATA00.DLL, DATA01.DLL, ... so I just formed the name by adding 1 to a 
> counter and
> generating the next DLL name and opening it, then iterating through its 
> resources, and so
> on.  So when I ran out of DLLs, I knew I had come to the end of the 
> available DLLs.
>
> If an update had fewer DLLs, I could then use the VERSIONINFO information 
> and older DLLs
> that were higher-numbered than the version of DATA00.DLL would be deleted.
>
> So if the rule is that it succeeds as admin and fails silently without 
> admin, is it really
> "failure"?
>
> The real problem is the erroneous assumption that there can only be one 
> users per machine,
> and the failures that accompany that flawed assumption.
> joe
>
> On Tue, 28 Oct 2008 09:27:27 -0600, "Jonathan Wood" 
> <jwood@softcircuits.com> wrote:
>
>>Tom,
>>
>>> It's unfair to say "doesn't work".  It works if all of the conditions 
>>> are
>>> right and the user is logged in as an administrator.
>>
>>You know..., there are folks looking to write reliable code. Such folks do
>>not consider code that fails more often than it works as "working." I 
>>think
>>it would be safe to put me in this category.
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
jwood (1292)
10/29/2008 12:54:21 AM
Can't argue much with that logic... :o)

Tom

"Jonathan Wood" <jwood@softcircuits.com> wrote in message 
news:uwvGzGROJHA.728@TK2MSFTNGP06.phx.gbl...
> Tom,
>
>> It's unfair to say "doesn't work".  It works if all of the conditions are 
>> right and the user is logged in as an administrator.
>
> You know..., there are folks looking to write reliable code. Such folks do 
> not consider code that fails more often than it works as "working." I 
> think it would be safe to put me in this category.
>
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 

0
tom.nospam (3240)
10/29/2008 4:44:04 AM
Reply:

Similar Artilces:

How To Create UI Automation Test Suites for VC++ 7.2 Application
Hi All Envoirement -: VC++ 7.2 OS -: Win 2000,XP As i can Develop UI Automation Test Suite For .NET Application Plz Anyone tell me,Can I Develop this Tool for VC++7.2 Application ? If yes ,How ? plz suggest me for it. Regards Tarandeep Singh tarandeep@abosoftware.com Fundamentally, this is hard. There are some commercial programs out there that do this, but getting a test suite that works well, particularly in all resolutions, and is fully scriptable, is a nontrivial problem (well, let's put it this way: I would not accept a fixed-price contract to do this, and wou...

Need help getting files from Exchange Server.
We have a computer that had an account on Outlook attached to a Microsoft exchange server. Apparently for the moment, this computer and the server are inextricably tied together. Outlook cannot even be started without logging into the server because information store or whatever is missing. How do you get the information out of the exchange server to wean the computer from it? tom <Spamblocker@ameritech.net> wrote: > We have a computer that had an account on Outlook > attached to a Microsoft exchange server. > > Apparently for the moment, this computer and the > se...

when i save a file that i have worked on, excel7 closes down work.
i have recently purchased office pro 2007. Excel 2007, when i save a filethat i have worked on, excel closes down and work is lost, done all updates, re installed from disc, please help i have lost 2 hours of work this moring that i need for a report a few questions: 1. what happens with save as? 2. what happens in safe mode? (hold shift key while starting excel) 3. do you have add-ins? 4. what operating system? x64? -- Gary Keramidas Excel 2003 "rob" <rob@discussions.microsoft.com> wrote in message news:0483F09B-3289-42B4-8849-0C0A61380B11@mic...

How to change .pst file location on hard drive(s)?
I want to move my .PST file c/w archives to a partition other than C:\. How can I do this with Win Live Mail? Thanks, John. "Machinist60" <e_john_wilson.no.spam.@hotmail.com> wrote in message news:hj5s5l$q8r$1@news.eternal-september.org... > I want to move my .PST file c/w archives to a partition other than C:\. > How can I do this with Win Live Mail? > > Thanks, John. I didn't realize WLM utilized the .pst file. I had to convert my .pst file data into the Windows Mail format and then import the data into WLM. Please explain what you...

Just saved file, cannot be found. ?
Even Global search ? Win 7 ... Whatz up? if you saved it, it should be in the mru list? what version of excel are you using? -- Gary Keramidas Excel 2003 "Boswell" <Boswell@discussions.microsoft.com> wrote in message news:E9D6ED74-ABC5-469D-9572-2D8AE93F36CD@microsoft.com... > Even Global search ? > > Win 7 ... > > Whatz up? one other question, how did you open it, outlook email? if that's the case, search will never find it. it is probably here: C:\Users\Your user name\AppData\Local\Microsoft\Windows\Temporary Intern...

Closing application
We have a networked Access database used by approx. 50 users in various locations. Is there a way via code or otherwise to close everyone out and quit them from the application when we need exclusive access to make updates and changes? ...

Excel 2003 file freezes laptop
I took a laptop away from the office and tried to open a large spreadsheet on the local C: drive. Each time I tried the laptop froze and had to be rebooted. When I connected back to the LAN at work, and opened the same file on the local C: drive I had no problems. What could cause this? If there is any corruption is there a way to decompile or something as you would in Access? Thanks, Mich ...

AFX_MANAGE_STATE() macro disturbs the startup position of the ATL dialog
Hi All, I have a MFC dialog based application and a COM component developed using ATL with MFC support. The COM component exposes an interface ISum that has a method called Add(). The Add() method displays an ATL dialog that accepts numbers from the user on which addition is to be performed and displays the result as well. The contents of the Add() method are as given below: STDMETHODIMP CSum::Add() { CAcceptInput dlg; dlg.DoModal(); return S_OK; } On click of one of its buttons, the MFC dialog application, instantiates the COM component and invokes the ISu...

Unattend configure Send/Receive Group / PRF file -Outlook XP
Hi, Have to rollout 4000 laptops with Offline Storage enabled. I want to automatically configure outlook to: - use OST file - Synchronize when logging on and off - Download and sync. the general address book I have made a PRF file (using CIW) that creates OST file...so far so good... But I can't unattend set the option to sync when logging on and off. It seems this setting is stored in an SRS file in the users profile!! Second item, default the first address book in the list is synchronised. Is there a way to auto configure Outlook XP to sync OST fiel when logging on and off, (ins...

How to search against XML files in the file system?
Putting the search textbox on the page is the easy part. What's preferred way to find terms in XML files located on the file system? Like finding stuff saved in XML files some of the blogs use these days to store their blog items? There can be lots and lots and lots of XML files on the file system to search. -- <%= Clinton Gallagher NET csgallagher AT metromilwaukee.com URL http://clintongallagher.metromilwaukee.com/ clintonG wrote: > Putting the search textbox on the page is the easy part. What's preferred > way to find terms in XML files located ...

OT: managing file fragmentation on external USB backup drive (SBS2003)
Just wondering how others are managing file fragmentation on their external USB backup drives (SBS 2003)? I have two WD 500GB drives that i rotate weekly (each backup is around 55GB currently) but periodically the server will "freeze" during a backup (fans on, but no response at all) and requires a hard reboot to get going again. The first time it did it, i had no idea what caused it, but on subsequent occurrences I narrowed it down to the external hard drive itself - after the reboot, simply trying to access the drive via Windows Explorer on the server caused the se...

Recovery excel file
Anybody knows if there is any free tools to recover a advanced excel file (using macro, graphics, formulas, and several formats)???????? Tks, Marcelo Rayol ...

worksheet labels based on cell results
How can I build a macro to use the contents of several cells in a column to label a corresponding number of worksheets with their contents. Ideally this would also build links to the tabs so that a user could click on a specific cell (in that column) and be redirected to the corresponding worksheet Thanks, Mitch Hi for labeling the tab try something like activesheet.name=activesheet.range("A1").value For the second question try using a Hyperlink (Insert - Hyperlink) -- Regards Frank Kabel Frankfurt, Germany Mitch wrote: > How can I build a macro to use the contents of ...

Help me create sales chart based on state and quantity
We have a production report on excel. It shows the details for our clients. Part of that data includes the state in which the client lives. We are trying to create a chart showing the percentages of each state( so we know where the most deals are closed) Any suggestions? Hello mr_merchant_man, this sounds like a job for a pivot table, using Average as the data calculation operator. Or, depending on your version of Excel, you can use AVERAGEIFS (in Excel 2007) or calculate an averate with a combination of SUMIF divided by COUNTIF. To be more specific, it would help to s...

Open 2003 files with 2007
Hello all, I just upgraded my Office 2003 with Office 2007 on an EP Pro machine. The only snaffoo I find(so far..) is with Excel 2007. When I double-click on an Excel 2003 file, Excel 2007 starts up just fine, BUT my file is not displayed. At that point if I click the Restore button up at top-right, the file appears when Excel is restored up or down, then all is well. Anyone have any idea whats up with that and how to fix it??? Thanks John Lots of people have complained that when they doubleclick on a file in windows explorer, that the workbook doesn't seem to show up in xl20...

Appending XML to an existing XML file
Hey all, I've read a few articles about speed and XML processing - so I just want to make sure that I'm using the right strategy for what I want to achieve. I have an XML file that I'm appending to every time a user submits their information. Right now I'm using XMLDocument (Load and Save) in conjuncture with XmlElement objects. Is this the right approach or is there a faster approach? Thanks, Novice PS Here is a simplified version of what I'm doing: XmlDocument xdoc = new XmlDocument(); xdoc.Load("results.xml"); XmlNode node = xdoc.SelectSingleNode("...

How do I export .dba calendar files from a Palm Treo to Outlook?
Chapura won't do it. Something about a problem with calendar files. ...

copy rows to another file
Dear Experts I have following code,i need to copy desirde rows to new file (r.xls) on sheet 1. This code is able to copy desired rows from active sheet to sheet2(same file) based on values in column G. Would you please guide me? regards Sub Marine() Dim arrParts() As String Dim MyRange As Range, CopyRange As Range Dim LastRow As Long LastRow = Cells(Cells.Rows.Count, "G").End(xlUp).Row Set MyRange = Range("G1:G" & LastRow) response = InputBox("Enter rows to copy in the format nnn,nnn,nn") arrParts = Split(response, ",") For Each ...

File Naming for Picture Order
I want my photos within a folder to appear in a certain order and want them in numberical order; however, when I put them in numerical order and get past 9 (into 2 digit numbers) the order gets all whacky. bjackson wrote: > I want my photos within a folder to appear in a certain order and > want them in numberical order; however, when I put them in numerical > order and get past 9 (into 2 digit numbers) the order gets all whacky. ======================= Instead of... 1, 2, 3,.....10, 11, 12... Try this... 0001, 0002, 0003,.....0010, 0011, 0012 If you are batch renumbering the f...

How to get the handle of a Help file belonging to other process.
Hi all, In my application,I want to change the Index of a HTMLHELP file which belongs to a dialog running in other exe.In order to do this I need to find whether the Help file is open or not & get the handle of that to use HH_DISPLAY_INDEX .Is there any way to do this?? Note: I dont want to use FindWindow() as it is giving rise to some problems in my application.. Thanks in advance ...

Add items from an external application to RMS transaction grid
Is there a way to add items from an external application to MS RMS transaction grid? I want to add items using windows application or web application to RMS transaction grid. Kindly help how to add from an external application. Thanks for help in advance. You would need an Add-in for RMS to make this happen. If you are yourself not sure how to make this happen, I would consult with your RMS partner, or any of the other partners on this forum, including my company, that specialize in creating customization for RMS. If you are interested in getting an estimate for this work please f...

Can't open files
Hello -- I'm sure this isn't the proper place to post my problem, but thought I'd start here anyways. Let me start off by saying that I'm extremely computer-stupid, so please forgive my ignorance. I'm running Windows Vista Ultimate, and yahoo email. For some reason, I'm unable to open attachments that have been sent to me, and saved to my computer. PLEASE HLP!! These are important documents that I really need to access. Thanks for your help -- It's not very informative to say you are not able to open attachments. What happens when you try? Is ther...

Using MFC dll from non-MFC application
I have been struggling several weeks with this problem. I need to call an MFC dll from a non-MFC application. The MFC dll was originally a working MFC program that I conveted to a dll. The dll works fine except that it crashes when I exit. Can anyone provide me with some snippets of working code showing how you did this? An example of the calling code, the CWinApp (or at least the InitInstance) and the hook function would be great. I have read several times that this should be easy to do, so I am probably just missing a simple line somewhere. The way I created my dll is to use to ...

access application
what are the applications of Microsoft Access ...

Money 2004 File Corruption
Since Tuesday every time I update my Money 2004 file it becomes corrupt. I have tried everything trying to fix the problem. Below are just a few of the steps: 1. Restore file from backup. 2. Run Salvage to make sure it clean/fixed (says file is ok), delete all files from Internet Explorer 3. Open Money file 4. Browse accounts... all work fine (no transactions to approve) 5. Update file online 6. Once complete , click ok and it takes me to the Account List 7. As soon as Account List updates with the accounts that have transactions that need approved I get an error that requires a restart 8. Sa...