Autor Beitrag
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Fr 21.02.03 12:18 
Maaaahlzeit.. :D

folgendes hab ich im swissdelphicenter gefunden, um eine Internetverbindung zu trennen bzw. herzustellen:

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:
uses 
  WinInet; 

// Causes the modem to automatically dial the default Internet connection. 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  dwConnectionTypes: DWORD; 
begin 
  dwConnectionTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + 
    INTERNET_CONNECTION_PROXY; 
  if not InternetGetConnectedState(@dwConnectionTypes, 0) then 
    // not connected 
    if not InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE or 
      INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) then 
    begin 
      // error 
    end; 
end; 


// hangup the default Internet connection. 
procedure TForm1.Button2Click(Sender: TObject); 
var 
  dwConnectionTypes: DWORD; 
begin 
  dwConnectionTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + 
    INTERNET_CONNECTION_PROXY; 
  if InternetGetConnectedState(@dwConnectionTypes, 0) then 
    // connected 
    InternetAutodialHangup(0); 
end;


Hab ich also ausprobiert, und mich schon wie ein kleines Kind gefreut, musste mich aber mit folgender Fehlermeldung zufriedengeben:

Zitat:
[Error] mainform.pas(69): Undeclared identifier: 'INTERNET_CONNECTION_MODEM'
[Error] mainform.pas(69): Undeclared identifier: 'INTERNET_CONNECTION_LAN'
[Error] mainform.pas(70): Undeclared identifier: 'INTERNET_CONNECTION_PROXY'
[....... geht dann immer so weiter......]


kennt einer vielleicht einen weg aus dem dillemma??

thx und mfg
kiwicht
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 21.02.03 13:10 
Einfach die Unit WinInet in die Uses-Liste einbinden.

Gruß
TINO
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Fr 21.02.03 13:26 
Tino hat folgendes geschrieben:
Einfach die Unit WinInet in die Uses-Liste einbinden.

Gruß
TINO


:?

kiwicht hat folgendes geschrieben:
Code:
uses
WinInet;


;) habsch doch...
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 21.02.03 13:38 
Sorry, habs in Deinen Code übersehen. Aber in dieser Unit sind die Konstanten definiert. Der Sourcecode den du gepostet hast ist wahrscheinlich direkt der von sdc, oder? Will heißen oder besser gesagt fragen ob Du die Unit auch in Deiner Anwendung hinzugefügt hast?

Gruß
TINO
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Fr 21.02.03 13:49 
np... ich habs jetzt nochmal probiert. will heissen:

programm geschlossen, nochmal neue app´ created, nochmal alles eingefügt.

-> funzt. hm, weiss nicht wieso,aber es geht halt... verrückte welt.... trotzdem vielen dank! :D

mfg