Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get startup folder 1

Status
Not open for further replies.

Eli20

Programmer
Oct 30, 2003
119
MX
hi, im doing a program in vb6.0 to create a bat file and i need to copy that bat file to the starup directory of my clients computer, but how can i know where it is exactly (it varies from win98 to xp and so)

is there a variable or a way to access it? or how can i look for it??

thank You very much

Eli
 
You could create a registry entry that would point to the .bat file and place it in the following key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
thank You paulbent, i tried your solution, but no matter what constant i send to the function i got as result the "My Documents" folder.. can You explain me a bit more how to use it??

thank you very much

Eli
 
Here's the much shorter version I've posted on a number of occasions (but cannot seem to find the old threads). Note the requirement for a reference to Microsoft Shell Controls and Automation to be set in your project:
[tt]
Private Sub Command1_Click()
MsgBox GetSpecialPath(ssfCOMMONSTARTUP)
End Sub

' vDir can be either one of the ShellSpecialFolder constants (start with ssf), or a normal path string
Public Function GetSpecialPath(vDir As ShellSpecialFolderConstants) As String
' Requires reference to Microsoft Shell Controls and Automation (SHDOC401.dll or Shell32.dll depending on OS version)

With New Shell32.Shell
' Should work for almost all versions of Shell32.dll (versions 4.71 and later on W95, W98)
' GetSpecialPath = .NameSpace(vdir).ParentFolder.ParseName(.NameSpace(vdir).Title).Path
' If you have shell32.dll version 5.0 or later (XP, W2000, Windows Me) you should use the following instead:
GetSpecialPath = .NameSpace(vDir).Self.Path
End With

End Function
 
Eli20,

Sorry about that, I pasted it from a couple of places, (one of which was in another language) and missed an edit:
Code:
Public Function fGetSpecialFolder(Byval lngCSIDL As Long) As String

 '--- Given a CSIDL constant, returns the path to a special folder

 Dim udtIDL As ITEMIDLIST
 Dim lngRtn As Long         'Return value
 Dim strFolder As String    'Buffer returned folder

 lngRtn = SHGetSpecialFolderLocation(Me.hWnd, _
 lngCSIDL, udtIDL)
 If lngRtn = 0 Then
  strFolder = Space$(260)
  lngRtn = SHGetPathFromIDList( _
  ByVal udtIDL.mkid.cb, ByVal strFolder)
  If lngRtn Then
   fGetSpecialFolder = Left$(strFolder, _
   InStr(1, strFolder, Chr$(0)) - 1)
  End If
 End If

End Function

In the original version, it wasn't using the passed in CSIDL parameter.

Paul Bent
Northwind IT Systems
 
thank You strongm Your code worked perfect.. but i have a question.. i dont know the version or windows my clients will have, can i use the shell 5.0 as default and it will work too with win98? or how can i find out what version windows is it, so i can know what line to execute??

thank you very much

Eli
 
Why didnt you check out the link I posted? You wouldnt be asking these questions???????
 
LPlates - did you check out the comments on the link you posted?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm - Did you download the code and test it out? Theres also a lot of functions he does not call in the demo for example how to get any special folder and a whole lot more. I find the code very usefull as a reference/example. I do not know why he recieved such a hard time over the code.
 
LPlates - No i didn't download it (it may be useful and it obviously has been to you) - I was just pointing out that that it had been given a bit of a bad review.

Bad user reviews may be something that stopped me downloading it in the first place...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Maybe because its an ocx and some people have a hard time trying to reference them etc, maybe he didnt include a group project, I can't remember now but I must have converted into a UserControl (judging by the multiple projects in the one folder) and it works very well, try it out and let me know what you think.
 
thank you very much paulbent, im using your code and it works great, it does exactly what i needed it to do, you saved me.. ;-)

Eli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top