PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
'// Kaynak: vbaccelerator.com
Public Enum eAutoRunTypes eNever eOnce eAlways End Enum
Public Property Let AutoRun(ByVal eType As eAutoRunTypes) Dim ***e As String
***e = App.Path If (Right$(***e, 1) <> "\") Then ***e = ***e & "\" ***e = ***e & App.EXEName
Dim cR As New cRegistry cR.ClassKey = HKEY_LOCAL_MACHINE If (eType = eNever) Then ' Remove entry from always Run if it is there: cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\Run" cR.ValueKey = App.EXEName On Error Resume Next cR.DeleteValue Err.Clear ' Remove entry from RunOnce if it is there: cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\RunOnce" On Error Resume Next cR.DeleteValue Err.Clear ElseIf eType = eOnce Then ' Remove entry from always Run if it is there: cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\Run" cR.ValueKey = App.EXEName On Error Resume Next cR.DeleteValue Err.Clear ' Add an entry to RunOnce (or just ensure the exe name and path ' is correct if it is already there): cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\RunOnce" cR.ValueKey = App.EXEName cR.ValueType = REG_SZ cR.Value = ***e Else ' Remove entry from RunOnce if it is there: cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\RunOnce" cR.ValueKey = App.EXEName On Error Resume Next cR.DeleteValue Err.Clear ' Add an entry to RunOnce (or just ensure the exe name and path ' is correct if it is already there): cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\Run" cR.ValueKey = App.EXEName cR.ValueType = REG_SZ cR.Value = ***e End If
End Property
Public Property Get AutoRun() As eAutoRunTypes Dim cR As New cRegistry cR.ClassKey = HKEY_LOCAL_MACHINE cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\Run" cR.ValueKey = App.EXEName cR.Default = "?" cR.ValueType = REG_SZ If (cR.Value = "?") Then cR.SectionKey = "Software\Microsoft\Windows\CurrentVersion\RunOnce" If (cR.Value = "?") Then AutoRun = eNever Else AutoRun = eOnce End If Else AutoRun = eAlways End If End Property