
Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
> Hi;
>
> What's the managed code way to get GetWindowsDirectory()?
>
> And if I want the fonts directory, is it safe to always just add "\fonts" to
> it?
You should be able to get the fonts directory location from the
following registry location:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders]
"Fonts"="C:\\WINDOWS\\Fonts"
Jesse Houwing
David Thielen - 14 Jun 2006 23:58 GMT
thank you

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
> > Hi;
> >
[quoted text clipped - 11 lines]
>
> Jesse Houwing
Greg Young - 15 Jun 2006 03:30 GMT
I would personally recommend using the environment class for this.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemenvironmentclasstopic.asp
Cheers,
Greg Young
>> Hi;
>>
[quoted text clipped - 11 lines]
>
> Jesse Houwing
David Thielen - 15 Jun 2006 04:10 GMT
Thank you. I can pass multiple directories so I think I'll use both methods
and if they differ, pass both.

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
> I would personally recommend using the environment class for this.
>
[quoted text clipped - 18 lines]
> >
> > Jesse Houwing
Greg Young - 15 Jun 2006 18:30 GMT
The problem is that the registry solution may not work in version x of
windows. The purpose of the Environment class is that it abstracts this from
you.
Cheers,
Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
> Thank you. I can pass multiple directories so I think I'll use both
> methods
[quoted text clipped - 24 lines]
>> >
>> > Jesse Houwing
If anyone else needs this:
// get it from the environment
String dir =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.System);
dir += "\\..\\fonts";
dir = System.IO.Path.GetFullPath(dir);
count += registerDirectory(dir);
// get it from the registry
Microsoft.Win32.RegistryKey regKey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
if (regKey != null)
{
Object obj = regKey.GetValue("Fonts");
regKey.Close();
if (obj instanceof String)
{
String dir2 = System.IO.Path.GetFullPath((String)obj);
if (! dir.toLowerCase().equals(dir2.toLowerCase()))
count += registerDirectory(dir2);
}
}

Signature
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com