Auto load VB5 Application


I just want to know how to to code a program that when WIN95 started it will automatically RUN(NOTE: not using startup).

Who is Participating?
MikeP090797Connect With a Mentor Commented:
Put this in a module:

Public Const REG_SZ = 1
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long

Put this in form_load:

Dim hKey As Long
RegOpenKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey

RegSetValue hKey, "", REG_SZ, App.Path & "\App.exe", Len(App.Path & "\App.exe")

alteclAuthor Commented:

I just want to clarify:

Once i made this program i have to compile it to exe and what directory should i put the EXE files of this porgram.

thank you
After you make the EXE, you can put it wherever you want. The code above registers it to run on startup using program's current location
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.