Special Folder Path

Special Folder Path

Question:
I want to find the path to the Startup special folder. How can this be done within a VB application?

Answer:
It takes a couple of steps, but is actually pretty easy:

  1. Start a new VB project.
  2. Open Notepad and copy the code below into Notepad. Save the file as SpecialGroups.frm.
  3. Add your just-saved SpecialGroups.frm file to your new project.
  4. Add a reference to the x:Microsoft Visual StudioVB98VBUNSUPPRTSHELLLNK Shelllnk.vbp to your project group.
  5. Run the program. By selecting the appropriate combo item, you can get the path of any of the special directories, including Startup.

Here’s the code to paste into your SpecialGroups.frm file in Notepad:

VERSION 5.00Begin VB.Form Form1    Caption         =   "Special Folders"   ClientHeight    =   1212   ClientLeft      =   876   ClientTop       =   1908   ClientWidth     =   5340   LinkTopic       =   "Form1"   ScaleHeight     =   1212   ScaleWidth      =   5340   Begin VB.ComboBox Combo1       Height          =   288      Left            =   144      Style           =   2  'Dropdown List      TabIndex        =   1      Top             =   216      Width           =   4872   End   Begin VB.Label Label1       BorderStyle     =   1  'Fixed Single      Height          =   300      Left            =   144      TabIndex        =   0      Top             =   612      Width           =   4872   EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitPrivate Sub Combo1_Click()    Dim rc As Long    Dim sLnk As cShellLink    Dim sfPath As String    Dim Id As Long        ' Create instance of Explorer's IShellLink Interface Base Class    Set sLnk = New cShellLink        Id = Me.Combo1.ItemData(Me.Combo1.ListIndex)    Me.Label1.Caption = ""    If sLnk.GetSystemFolderPath(Me.hwnd, Id, sfPath) Then      Me.Label1.Caption = sfPath    End If        Set sLnk = NothingEnd SubPrivate Sub Form_Load()        With Me.Combo1        .AddItem "DESKTOP"        .ItemData(.NewIndex) = 0        .AddItem "PROGRAMS"        .ItemData(.NewIndex) = &H2        .AddItem "Controls"        .ItemData(.NewIndex) = &H3        .AddItem "Printers"        .ItemData(.NewIndex) = &H4        .AddItem "PERSONAL"        .ItemData(.NewIndex) = &H5        .AddItem "FAVORITES"        .ItemData(.NewIndex) = &H6        .AddItem "STARTUP"        .ItemData(.NewIndex) = &H7        .AddItem "RECENT"        .ItemData(.NewIndex) = &H8        .AddItem "SENDTO"        .ItemData(.NewIndex) = &H9        .AddItem "BITBUCKET: RECYCLE-BIN"        .ItemData(.NewIndex) = &HA        .AddItem "STARTMENU"        .ItemData(.NewIndex) = &HB        .AddItem "DESKTOPDIRECTORY"        .ItemData(.NewIndex) = &H10        .AddItem "DRIVES"        .ItemData(.NewIndex) = &H11        .AddItem "NETWORK"        .ItemData(.NewIndex) = &H12        .AddItem "NETHOOD"        .ItemData(.NewIndex) = &H13        .AddItem "Fonts"        .ItemData(.NewIndex) = &H14        .AddItem "TEMPLATES"        .ItemData(.NewIndex) = &H15        .AddItem "COMMON_STARTMENU"        .ItemData(.NewIndex) = &H16        .AddItem "COMMON_PROGRAMS"        .ItemData(.NewIndex) = &H17        .AddItem "COMMON_STARTUP"        .ItemData(.NewIndex) = &H18        .AddItem "COMMON_DESKTOPDIRECTORY"        .ItemData(.NewIndex) = &H19        .AddItem "APPDATA"        .ItemData(.NewIndex) = &H1A        .AddItem "PRINTHOOD"        .ItemData(.NewIndex) = &H1B                .ListIndex = 0    End WithEnd Sub

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as