Results 1 to 13 of 13

Thread: [2005] get folders

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2007
    Posts
    104

    [2005] get folders

    Hi,
    what is the way to get url of system folders such as window , fonts ??

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2005] get folders

    You can use System.Environment.GetFolderPath to get the directory for special folders, however I am not sure that Fonts is considered a special folder.

    For example:
    vb Code:
    1. MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.System))

    Will return your System32 folder.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    Yes, use the SpecialDirectories function of the FileIO class.
    Code:
    OpenFileDialog1.InitialDirectory = FileIO.SpecialDirectories.MyDocuments
    Edit: The Fonts directory isnt acccessible under this class though
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2005] get folders

    I did a little reading and it looks like you would have to use the SHGetSpecialFolderLocation API to get the Fonts Folder.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    I guess you could just get the Windows directory and append "\Fonts" to it...

    Or use the SHGetSpecialFolderLocation API and pass the CSIDL_FONTS constant to it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    I wrote this up as I was curious to see the diffs from VB 6 to VB.NET.
    Code:
    Option Explicit On
    Option Strict On
    
    Imports System.Text
    Imports System.Runtime.InteropServices
    
    Public Class Form1
    
    	Private Const CSIDL_FONTS As Int32 = &H14
    
    	<StructLayout(LayoutKind.Sequential)> _
    	Public Structure SHTEMID
    		Dim cb As IntPtr
    		Dim abID As Byte
    	End Structure
    
    	<StructLayout(LayoutKind.Sequential)> _
    	Public Structure ITEMIDLIST
    		Dim mkid As SHTEMID
    	End Structure
    
    	<DllImport("shell32.dll", CharSet:=CharSet.Auto, EntryPoint:="SHGetPathFromIDList")> _
    	Public Shared Function SHGetPathFromIDListW(ByVal pidl As IntPtr, <MarshalAs(UnmanagedType.LPTStr)> ByVal pszPath As StringBuilder) As Boolean
    	End Function
    
    	<DllImport("shell32.dll", CharSet:=CharSet.Auto, EntryPoint:="SHGetSpecialFolderLocation")> _
    	Public Shared Function SHGetSpecialFolderLocation(ByVal hwnd As IntPtr, ByVal csidl As Int32, ByRef ppidl As ITEMIDLIST) As Int32
    	End Function
    
    	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    		Dim ret As Integer, itm As ITEMIDLIST
    		ret = SHGetSpecialFolderLocation(Me.Handle, CSIDL_FONTS, itm)
    		If ret = 0 Then
    			Dim buff As New StringBuilder(" ", 512)
    			Dim bret As Boolean
    			bret = SHGetPathFromIDListW(itm.mkid.cb, buff)
    			MessageBox.Show(buff.ToString)
    		End If
    	End Sub
    
    End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2007
    Posts
    104

    Re: [2005] get folders

    Quote Originally Posted by RobDog888
    I guess you could just get the Windows directory and append "\Fonts" to it...

    what is the way to get windows folder?
    then i want open that folder , what i must do?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    You can just pass the windows clsid const with my previous code but I thought you wanted the Fonts dir?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2007
    Posts
    104

    Re: [2005] get folders

    yes

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    I think the confusion came from not enough description before my code
    It can directly get the Fonts directory.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] get folders

    Dear Robert,
    Sorry for hacking these post. Where can i found that DllImport Functions.Is there any Offline utiltity avaliable. I tried one from Pinvoke.net,but it is that not effective

    Dana
    Please mark you thread resolved using the Thread Tools as shown

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] get folders

    No prob. Its easy to format.

    Code:
    <DllImport("filename", CharSet:=CharSet.Auto, EntryPoint:="name of api")> _
    I find that the API Viewer utility is still better then pinvoke.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] get folders

    Ohhhhhh. I already have this one.......... But I missed that one.. Now I got this one.
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width