Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21359

Problem when implement "SpecialFolderLocation"

$
0
0
Hello All :)
I have problem when i get startupmenu location path to combine with Application EXE Name.
here the complete code:
Code:

Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hwnd As Long, ByVal nFolder As Long, Pidl As Long) As Long

Declare Function SHGetPathFromIDList Lib "shell32" (Pidl As Long, ByVal FolderPath As String) As Long
    Const CSIDL_COMMON_STARTUP = 24
    Const MAX_PATH = 260

Public Function StartupMenu() As String
    Dim lpStartupPath As String * MAX_PATH
    Dim Pidl As Long
    Dim hResult As Long
   
    hResult = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, Pidl)


    If hResult = 0 Then
        hResult = SHGetPathFromIDList(ByVal Pidl, lpStartupPath)


        If hResult = 1 Then
            lpStartupPath = Left(lpStartupPath, InStr(lpStartupPath, Chr(0)) - 1)
            StartupMenu = lpStartupPath
        End If
    End If
End Function

Private Sub Form_Load()
 S = StartupMenu
 sDest = S & "\" & App.EXEName & ".EXE"
End Sub

problem is here:
Code:

sDest = S & "\" & App.EXEName & ".EXE"
because sDest always give startUpPath location "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\"
should be "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\myapp.exe"

but, when i do manually, this is work:
Code:

S = "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\" & App.EXEName & ".EXE"
but this is not what i want, i want to use this way :
sDest = S & "\" & App.EXEName & ".EXE"

Anyone know to solve my problem..

thank you

Viewing all articles
Browse latest Browse all 21359

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>