Autor Beitrag
grilly
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: So 21.01.07 21:08 
Hallo
Ich hab ein hübsches Programm geschreiben, dass daten vom ftp server holt. die XP firewall steht im weg und ich hab von den schweizern einen code zum ausschalten der firewall


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
uses
  Windows, winsvc, shellapi;
  
procedure Close_Firewal;
var
  SCM, hService: LongWord;
  sStatus: TServiceStatus;
begin
  SCM      := OpenSCManager(nilnil, SC_MANAGER_ALL_ACCESS);
  hService := OpenService(SCM, PChar('SharedAccess'), SERVICE_ALL_ACCESS);

  ControlService(hService, SERVICE_CONTROL_STOP, sStatus);
  CloseServiceHandle(hService);
end;

begin
  Close_Firewal;
end.



Alles schön und gut, und das funzt ja auch, aber wie kann ich die firewall wieder einschalten? (nicht per hand!)

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Steven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 21.01.07 21:32 
so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure Start_Firewal; 
var 
  SCM, hService: LongWord; 
  sStatus: TServiceStatus; 
  lpServiceArgVectors: PChar; 
begin 
  SCM      := OpenSCManager(nilnil, SC_MANAGER_ALL_ACCESS); 
  hService := OpenService(SCM, PChar('SharedAccess'), SERVICE_ALL_ACCESS); 

  StartService(hService,0,lpServiceArgVectors); 

  CloseServiceHandle(hService); 
end;

gruss vom steven
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 21.01.07 21:36 
Ab Delphi 6 brauch man für die Übergabe von PChars den expliziten Typecast nicht mehr angeben (wenn man einen Stringliteral übergibt).

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Steven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 21.01.07 22:03 
hi...
so steht's in der unit WinSvc:
ausblenden Delphi-Quelltext
1:
2:
function StartService(hService: SC_HANDLE; dwNumServiceArgs: DWORD;
  var lpServiceArgVectors: PChar): BOOL; stdcall;

Gruss Steven
grilly Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: So 21.01.07 22:37 
Danke für die schnellen antworten!
Ich versteh zwar nicht wies funktioniert, aber ich sehe, dass es funktioniert!^^