Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / June 2006

Tip: Looking for answers? Try searching our database.

GetWindowsDirectory() in .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 14 Jun 2006 22:03 GMT
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?

Signature

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

Jesse Houwing - 14 Jun 2006 23:46 GMT
> 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
David Thielen - 15 Jun 2006 17:09 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.