Hello, i have a problem, supposedly, i need windows to start my program at startup, and i know that one way is to register my app in the :"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun"
key, but whenever I use the function savesetting() It only generates a new folder in the registry under :"HKEY_CURRENT_USERSoftwareVB and VBA Program Settings" do you know a function that can access the main windows registry and modify it?, if not, do you know of other ways to make windows automatically start my program on startup?, thanks
Comments
: key, but whenever I use the function savesetting() It only generates a new folder in the registry under :"HKEY_CURRENT_USERSoftwareVB and VBA Program Settings" do you know a function that can access the main windows registry and modify it?, if not, do you know of other ways to make windows automatically start my program on startup?, thanks
:
:
Hi,
SaveSettings and LoadSettings are only for your internal configuration.. To add key into Run use this
[code]Dim hKey As Long, ret As Long
Dim Content As String
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"SoftwareMicrosoftWindowsCurrentVersion", _
0, KEY_ALL_ACCESS, hKey)
If ret = 0 Then
Content = "MyApp.exe"
UpdateKey hKey, "Run", Content, Content
RegCloseKey hKey
End If[/code](This example uses the same for key and value, and supposes MyApp.exe is located in some system path..)
You'll need to add some API functions into your code, of course..
[blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
[purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
: : key, but whenever I use the function savesetting() It only generates a new folder in the registry under :"HKEY_CURRENT_USERSoftwareVB and VBA Program Settings" do you know a function that can access the main windows registry and modify it?, if not, do you know of other ways to make windows automatically start my program on startup?, thanks
: :
: :
: Hi,
: SaveSettings and LoadSettings are only for your internal configuration.. To add key into Run use this
: [code]Dim hKey As Long, ret As Long
: Dim Content As String
: ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
: "SoftwareMicrosoftWindowsCurrentVersion", _
: 0, KEY_ALL_ACCESS, hKey)
: If ret = 0 Then
: Content = "MyApp.exe"
: UpdateKey hKey, "Run", Content, Content
: RegCloseKey hKey
: End If[/code](This example uses the same for key and value, and supposes MyApp.exe is located in some system path..)
: You'll need to add some API functions into your code, of course..
:
: [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
:
: [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
:
:
:
Thank you very much on this one, can i ask some more?, what api function should I declare? ^^;
thank you
"A mind is a teribble thing to waste"
-Yuri's revenge
: : : key, but whenever I use the function savesetting() It only generates a new folder in the registry under :"HKEY_CURRENT_USERSoftwareVB and VBA Program Settings" do you know a function that can access the main windows registry and modify it?, if not, do you know of other ways to make windows automatically start my program on startup?, thanks
: : :
: : :
: : Hi,
: : SaveSettings and LoadSettings are only for your internal configuration.. To add key into Run use this
: : [code]Dim hKey As Long, ret As Long
: : Dim Content As String
: : ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
: : "SoftwareMicrosoftWindowsCurrentVersion", _
: : 0, KEY_ALL_ACCESS, hKey)
: : If ret = 0 Then
: : Content = "MyApp.exe"
: : UpdateKey hKey, "Run", Content, Content
: : RegCloseKey hKey
: : End If[/code](This example uses the same for key and value, and supposes MyApp.exe is located in some system path..)
: : You'll need to add some API functions into your code, of course..
: :
: : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
: :
: : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
: :
: :
: :
: Thank you very much on this one, can i ask some more?, what api function should I declare? ^^;
: thank you
: "A mind is a teribble thing to waste"
: -Yuri's revenge
:
:
[code]
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const SYNCHRONIZE = &H100000
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long[/code]There's a long list of consts beacuse of KEY_ALL_ACCESS is built from them. You can evaluate that expression and save lines of code, of course..
btw, google and msdn usually tells you api's headers, if you don't have Api plugin (witch is std part of Visual Studio).
I hope those were all..
[blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
[purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
: : : : key, but whenever I use the function savesetting() It only generates a new folder in the registry under :"HKEY_CURRENT_USERSoftwareVB and VBA Program Settings" do you know a function that can access the main windows registry and modify it?, if not, do you know of other ways to make windows automatically start my program on startup?, thanks
: : : :
: : : :
: : : Hi,
: : : SaveSettings and LoadSettings are only for your internal configuration.. To add key into Run use this
: : : [code]Dim hKey As Long, ret As Long
: : : Dim Content As String
: : : ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
: : : "SoftwareMicrosoftWindowsCurrentVersion", _
: : : 0, KEY_ALL_ACCESS, hKey)
: : : If ret = 0 Then
: : : Content = "MyApp.exe"
: : : UpdateKey hKey, "Run", Content, Content
: : : RegCloseKey hKey
: : : End If[/code](This example uses the same for key and value, and supposes MyApp.exe is located in some system path..)
: : : You'll need to add some API functions into your code, of course..
: : :
: : : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
: : :
: : : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
: : :
: : :
: : :
: : Thank you very much on this one, can i ask some more?, what api function should I declare? ^^;
: : thank you
: : "A mind is a teribble thing to waste"
: : -Yuri's revenge
: :
: :
: [code]
: Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
:
: Public Const HKEY_LOCAL_MACHINE = &H80000002
:
: Public Const REG_SZ = 1
: Public Const REG_DWORD = 4
: Public Const STANDARD_RIGHTS_ALL = &H1F0000
: Public Const KEY_QUERY_VALUE = &H1
: Public Const KEY_SET_VALUE = &H2
: Public Const KEY_CREATE_SUB_KEY = &H4
: Public Const KEY_ENUMERATE_SUB_KEYS = &H8
: Public Const KEY_NOTIFY = &H10
: Public Const KEY_CREATE_LINK = &H20
: Public Const SYNCHRONIZE = &H100000
: Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
:
: Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long[/code]There's a long list of consts beacuse of KEY_ALL_ACCESS is built from them. You can evaluate that expression and save lines of code, of course..
:
: btw, google and msdn usually tells you api's headers, if you don't have Api plugin (witch is std part of Visual Studio).
:
: I hope those were all..
:
: [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
:
: [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
:
:
:
thank you very much,
my app will be finished soon,
hope I'm not much of a burden ^^;
"A mind is a teribble thing to waste"
-Yuri's revenge