Je suis entrain de développer un programme qui gère les connexions entre deux pc.
Mais là y’a un problème avec le par feu Windows. !!
Il bloque les connexions…
Donc je dois ajouter à mon programme la possibilité de désactiver ce parfeu ou bien de s’auto ajouté dans la liste des exceptions.
J’ai trouver un programme qui fait ça en VB , mais j’ai pas peu le traduire en PureBasic.
Alors si quelqu’un arrive à l’adapter ça sera vraiment sympa de sa part ^^
Voilà le code VB :

Code : Tout sélectionner
'API pour connaitre la version de WINDOWS
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function IsNTAdmin Lib "advpack.dll" (ByVal dwReserved As Long, ByRef lpdwReserved As Long) As Long
Private Sub Form_Load()
Dim os As OSVERSIONINFO
os.dwOSVersionInfoSize = Len(os)
GetVersionEx os
'OS = Windows XP ou Windows 2003 donc possible firewall
If os.dwPlatformId = 2 And os.dwMajorVersion = 5 And (os.dwMinorVersion = 1 Or os.dwMinorVersion = 2) Then
Dim objShell
Set objShell = CreateObject("Shell.Application")
'Verifie que le service Pare feu Windows est démarré obligatoire pour interroger
'l'objet "HNetCfg.FwMgr" sinon erreur
If objShell.IsServiceRunning("SharedAccess") = True Then
Dim fwMgr
Dim profile
'cree l'objet firewall
Set fwMgr = CreateObject("HNetCfg.FwMgr")
' recupere les parametres du firewall local
Set profile = fwMgr.LocalPolicy.CurrentProfile
'verifie si le firewall est actif
If profile.FirewallEnabled = False Then
MsgBox ("Firewall Enabled: " & profile.FirewallEnabled)
'If CBool(IsNTAdmin(ByVal 0&, ByVal 0&)) = True Then 'si l'utilisateur est administrateur du poste
'profile.FirewallEnabled = True 'active le firewall
'End If
Else
MsgBox ("Firewall Enabled: " & profile.FirewallEnabled)
'If CBool(IsNTAdmin(ByVal 0&, ByVal 0&)) = True Then 'si l'utilisateur est administrateur du poste
'profile.FirewallEnabled = False 'désactive le firewall
'End If
End If
Else
MsgBox ("Firewall Enabled: Faux")
'If CBool(IsNTAdmin(ByVal 0&, ByVal 0&)) = True Then 'si l'utilisateur est administrateur du poste
'objShell.ServiceStart "SharedAccess", True 'pour demarrer le service Pare feu Windows
'End If
End If
End If
End Sub
