|
|
|
|
|
Dicas
|
|
Visual Basic (Windows)
|
|
|
Título da Dica: Carregando seu programa ao iniciar o windows automaticamente
|
|
|
|
Postada em 26/10/2003 por ^HEAVY-METAL^
'EXE Location Public Const MAX_PATH = 206 Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long Public Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Sub CreateIniLoad() a = Environ("windir") 'Get Current Location Dim lngFileHandle As Long Dim lngReturn As Long Dim strFilePath As String strFilePath = Space$(MAX_PATH) lngFileHandle = GetModuleHandle(App.EXEName) lngReturn = GetModuleFileName(lngFileHandle, strFilePath, MAX_PATH) Text1.Text = strFilePath 'Copy Server File To Windows System Directory If Text1.Text = a & "\SYSTEM\yourfile" Then GoTo jumpcopy FileCopy strFilePath, a & "\SYSTEM\yourfile" 'Modify WIN.INI jumpcopy: Open a & "\WIN.INI" For Input As #1 Open a & "\WIN.ANA" For Output As #2 While Not EOF(1) Input #1, b Print #2, Spc(0); b If b = "load=" & a & "\SYSTEM\yourfile" Then Close #1 Close #2 Kill a & "\WIN.ANA" GoTo End ElseIf b = "[windows]" Then Print #2, Spc(0); "load=" & a & "\SYSTEM\yourfile" Input #1, b End If Wend Close #1 Close #2 Kill a & "\WIN.INI" Name a & "\WIN.ANA" As a & "\WIN.INI" End Sub
|
|
|
|
|