레지스트리에 추가하는 내용입니다.
그냥 모듈에 추가하셔서 사용 (call 해서 불러 쓰면 됩니다.) 하시면 될 듯 해요.
6.0 보다는 많이 간단해진 것 같네요.
P.S. Path = Application.StartupPath & "\test.exe" 대신에
Path = Application.ExecutablePath 를 쓰는게 더 좋을듯 하는군요.
(파일이름을 직접 넣어줘야하니.. 불편할테고. 이름이 바뀌면 못쓰겠죠?^^;)
vnote
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" ( _
ByVal Hkey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
ByVal lpSecurityAttributes As Long, _
phkResult As Long, _
lpdwDisposition As Long _
) As Long
' 레지스트리 닫기
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
' 레지스트리 문자열 값 설정...
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" ( _
ByVal Hkey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
ByVal lpValue As String, _
ByVal cbData As Long _
) As Long
'변수 선언(레지스터에 실행 등록할 주소)
Public Const KeyName$ = "Softwaremicrosoftwindowscurrentversion"
'실행 함수
Public Sub Installing()
Dim sName$, KName$, vinstelling$
sName = "run"
KName = "교통안내단말기 v1.0"
vinstelling = App.Path & "" & App.EXEName '실행디렉토리명과 실행파일명
Dim hNewKey As Long
Dim lRetVal As Long
lRetVal = RegCreateKeyEx(&H80000002, KeyName & "" & sName$, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
lRetVal = SetValueEx(hNewKey, KName$, REG_SZ, vinstelling$)
RegCloseKey (hNewKey)
End Sub
'레지스트리 값 설정 함수
Public Function SetValueEx(ByVal Hkey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
SetValueEx = RegSetValueExString(Hkey, sValueName, 0&, lType, vValue, Len(vValue))
End Function
'실행시 함수 호출
Call Installing
이 댓글을