X
تبلیغات
رایتل
دوشنبه 10 تیر‌ماه سال 1387 ساعت 12:54 ب.ظ

با این کد می تونید برنامه هاتون رو موقع شروع ویندوز صدا بزنید

 


Private Sub Form_Load()
Dim hregkey As Long
Dim subkey As String
Dim stringbuffer As String

subkey = "Software|Microsoft|Windows|CurrentVersion|Run"

retval = RegOpenKeyEx(HKEY_CURRENT_USER, subkey, 0, KEY_WRITE, hregkey)
If retval <> 0 Then
Debug.Print "Can't open the subkey"
Exit Sub
End If
stringbuffer = App.Path & "" & App.EXEName & ".exe" & vbNullChar
retval = RegSetValueEx(hregkey, "My App", 0, REG_SZ, ByVal stringbuffer, Len(stringbuffer))

RegCloseKey hregkey
End Sub
''''''''''''''''this code goes to a module

Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long

Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal _
hKey As Long) As Long

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_CURRENT_USER = &H80000001
Public Const KEY_WRITE = &H20006
Public Const REG_SZ = 1


فقط یادتون باشه بجای | علامت بک اسلش بزارین

del.icio.us  digg  newsvine  furl  Y!  smarking  segnalo