Autor Beitrag
dude
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Di 08.04.03 13:08 
Hi alle,
ich hab ja nur nach langem, und mit eurer Hilfe, einen nach mir angepassten Internet-Timer programmiert ( wer ihn mal anschauen will hier www.georg-graf.tk/ (funktioniert erst ab 9.4 wegen arbeiten.)) . Nun hab ich das Problem, nachdem ich eine neue Internet-Erkenn-Funktion eingebaut habe, kann ich meinen PC nicht mehr herunterfahren, weil der PC das Programm nicht schliessen kann (manuell gehts). ER bringt aber auch keine Meldung !

Quelltext:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
uses registry, ShellAPI;

const
  cERROR_BUFFER_TOO_SMALL = 603;
  cRAS_MaxEntryName = 256;
  cRAS_MaxDeviceName = 128;
  cRAS_MaxDeviceType = 16;

type
  TConnectionType = (ctNone, ctProxy, ctDialup);
  ERasError = class(Exception);
    HRASConn = DWord;
    PRASConn = ^TRASConn;
    TRASConn = record
      dwSize: DWORD;
      rasConn: HRASConn;
      szEntryName: array[0..cRAS_MaxEntryName] of Char;
      szDeviceType: array[0..cRAS_MaxDeviceType] of Char;
      szDeviceName: array [0..cRAS_MaxDeviceName] of char;
    end;
    TRasEnumConnections = function (RASConn: PrasConn; var BufSize: DWord;
     var Connections: DWord): LongInt; stdcall;

function ConnectedToInternet: TConnectionType;
function RasConnectionCount: Integer;
function ConnectedToInternet: TConnectionType;
var Reg: TRegistry;
  bUseProxy: Boolean;
  UseProxy: LongWord;
begin
  Result := ctNone;
  Reg := TRegistry.Create;
  with REG do
    try
      try
        RootKey := HKEY_CURRENT_USER;
        if OpenKey('Software\Microsoft\WindowsCurrentVersion\Internet settings',
        false) then begin
          if GetDataType('ProxyEnable') = rdBinary then
            ReadBinaryData('ProxyEnable', UseProxy, SizeOf(LongWord))
          else begin
            bUseProxy := ReadBool('ProxyEnable');
            if bUseProxy then UseProxy := 1
            else UseProxy := 0;
          end;
          if (UseProxy<>0) and (ReadString('ProxyServer')<>'' ) then Result := ctProxy;
        end;
      except
      end;
    finally
      Free;
    end;
    if Result = ctNone then begin
      if RasConnectionCount > 0 then Result := ctDialup;
    end;
end;

function RasConnectionCount: Integer;
var RasDLL: HInst;
  Conns: array[1..4] of TRasConn;
  RasEnums: TRasEnumConnections;
  BufSize: DWord;
  NumConns: DWord;
  RasResult: Longint;
begin
  Result := 0;
  RasDLL := LoadLibrary('rasapi32.dll');
  if RasDLL = 0 then exit;
  try
    RasEnums := GetProcAddress(RasDLL,'RasEnumConnectionsA');
    if @RasEnums = nil then
      raise ERasError.Create('RasEnumConnectionsA not found in rasapi32.dll');
    Conns[1].dwSize := Sizeof (Conns[1]);
    BufSize := SizeOf(Conns);
    RasResult := RasEnums(@Conns, BufSize, NumConns);
    if (RasResult = 0) or (Result = cERROR_BUFFER_TOO_SMALL) then Result := NumConns;
  finally
    FreeLibrary(RasDLL);
  end;
end;

procedure TaskBarAddIcon;
var
  tnid: TNOTIFYICONDATA ;
begin
  with tnid do
  begin
    cbSize := sizeof(TNOTIFYICONDATA);
    Wnd := Form1.handle;
    uID := 1;
    uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
    uCallbackMessage := WM_TASKBAREVENT;
    hIcon := application.icon.handle;
  end;

  strcopy(tnid.szTip,'Internet-Timer v2.1');
  Shell_NotifyIcon(NIM_ADD, @tnid);
end;


Ich glaub das ist alles vom Code. Den hab ich kopiert (ich weiss das ist nicht gut...). Ach ja, der Timer sucht jede Sekunde nach der InternetVerbindung.
Woran liegt das ??
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 08.04.03 13:43 
frage: wie schliesst du das programm manuell?

mit close?

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
dude Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Mi 09.04.03 15:13 
nix frage, wie schließt man manuell.

Ich will wissen an was der Fehler liegt.

Das Problem ist, dass mein Timer nicht von Windows geschlossen werden kann !!!
Dann, villeicht würde da auch eine Abfrage funktionieren, wie man von Windows abfragen kann, wann es heruntergefahren wird . Dann könnte ich das close oder Application.terminat benutzen.
Aber dafür müsste ich wissen wie man das von windows abfragen kann.

Frage::::!!!! Weiss jemand wie das geht ?!!!