|
-
Oct 30th, 2007, 02:30 PM
#1
Thread Starter
Lively Member
[2005] get folders
Hi,
what is the way to get url of system folders such as window , fonts ??
-
Oct 30th, 2007, 03:36 PM
#2
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:
MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.System))
Will return your System32 folder.
-
Oct 30th, 2007, 03:39 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 30th, 2007, 03:52 PM
#4
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.
-
Oct 30th, 2007, 03:53 PM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 30th, 2007, 04:29 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 31st, 2007, 03:25 AM
#7
Thread Starter
Lively Member
Re: [2005] get folders
 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?
-
Oct 31st, 2007, 03:42 AM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 31st, 2007, 04:01 AM
#9
Thread Starter
Lively Member
Re: [2005] get folders
yes
-
Oct 31st, 2007, 04:03 AM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 31st, 2007, 04:09 AM
#11
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
-
Oct 31st, 2007, 04:16 AM
#12
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 31st, 2007, 04:44 AM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|