InternetCheckConnection не хочет работать

Discussion in 'WASM.NETWORKS' started by medal, Jan 23, 2005.

Thread Status:
Not open for further replies.
  1. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    Подскажите формат InternetCheckConnection, а то все FALSE да FALSE.
     
  2. ProgramMan

    ProgramMan New Member

    Blog Posts:
    0
    Joined:
    Jan 13, 2004
    Messages:
    263
    InternetCheckConnection

    BOOL InternetCheckConnection(

    IN LPCSTR lpszUrl,

    IN DWORD dwFlags,

    IN DWORD dwReserved

    );



    Allows an application to check if a connection to the Internet can be established.



    Returns TRUE if a connection is made successfully, or FALSE otherwise. UseGetLastError to retrieve the error code. ERROR_NOT_CONNECTED is returned by GetLastError if a connection cannot be made or if the sockets database is unconditionally offline.

    lpszUrl

    Address of a string containing the Uniform Resource Locator (URL) to use to check the connection. This value can be set to NULL.

    dwFlags

    Unsigned long integer value containing the flag values. FLAG_ICC_FORCE_CONNECTION is the only flag that is currently available. If this flag is set, it forces a connection. A sockets connection is attempted in the following order:

    If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host.

    If lpszUrl is NULL and there is an entry in WinInet's internal server database for the nearest sever, the host value is extracted from the entry and used to ping that server.

    dwReserved

    Reserved, must be zero.
     
  3. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    С этим все ясно. Но при реализации - не получается, может кто сможет пару строчек (можно с invoke или классикой), у меня, по крайней мере, никак.
     
  4. IceStudent

    IceStudent Active Member

    Blog Posts:
    0
    Joined:
    Oct 2, 2003
    Messages:
    4,300
    Location:
    Ukraine
    Поищи в гугле, а лучше покопай RSDN
     
  5. amitophia

    amitophia New Member

    Blog Posts:
    0
    Joined:
    Mar 28, 2004
    Messages:
    44
  6. varnie

    varnie New Member

    Blog Posts:
    0
    Joined:
    Jan 2, 2005
    Messages:
    1,785
    а ты попробуй ее поюзать, вырубив свой фаервол.



    ps: сорри за оффтоп, но у меня почему-то MAPILogon возвращает в ЕАХе не нуль, а 2. кто знает?
     
  7. ganes

    ganes New Member

    Blog Posts:
    0
    Joined:
    Dec 7, 2004
    Messages:
    62
    Location:
    Ukraine
    Есть еще GetConnectionState() Вродь правильно написал,

    короче в ВинИнет.ДЛЛ оно или як-то похожее название дллКи и !00% пашет везде (Кроме Доса и Никсов)Если тебе связь

    с интернетом проверить то не парся с InternetCheckConnection()
     
  8. KiNDeR

    KiNDeR New Member

    Blog Posts:
    0
    Joined:
    Jun 13, 2003
    Messages:
    258
    Location:
    Russia
    Если я правильно вас понял вам надо проверять соединение с инетом? вот рабочий код...
    Code (Text):
    1.  
    2. ; for FASM 1.53
    3. ;
    4. ; (c) 2004, NaL :: [HI-TECH]
    5. ;
    6. ;
    7.     format PE GUI 4.0 on '%fasminc%/null.stub'
    8.     entry _start
    9.     stack 10000h
    10.  
    11.     include '%fasminc%/win32a.inc'
    12.     include '%fasminc%/macro/fasm32.mac'
    13.  
    14. ;
    15. ; ###################################################################### ###
    16. ;
    17.   section '.code' code readable executable
    18. ;
    19. ; ###################################################################### ###
    20. ;
    21.  _start:
    22.           align 4
    23.           xor     ebx,ebx
    24.           ; Создаем мютекс
    25.           @call   [CreateMutex],ebx,ebx,mutex_name
    26.           mov     [h_mutex],eax
    27.           ; Если мютекс уже создан, то выходим
    28.           call    [GetLastError]
    29.           or      eax,eax
    30.           jnz     exit.2
    31.  
    32.           ; Скрываем по Ctrl+Alt+Del
    33.           @call   [GetModuleHandle],kernel32_dll
    34.           or      eax,eax
    35.           jz      @F
    36.           @call   [GetProcAddress],eax,krnl_func
    37.           or      eax,eax
    38.           jz      @F
    39.           @call   eax,ebx,1
    40.  
    41.           @@:
    42.           ; Получим указатель на коммандную строку
    43.           call    [GetCommandLine]
    44.           mov     edi,eax
    45.           mov     ecx,MAX_PATH
    46.           mov     al,byte [edi]
    47.           cmp     al,22h
    48.           jne     @F
    49.           inc     edi
    50.           repne   scasb
    51.           @@:
    52.           mov     al,20h
    53.           repne   scasb
    54.           cmp     byte [edi],bl
    55.           jz      exit.1
    56.  
    57.           mov     esi,edi
    58.           mov     edi,bat_path
    59.           @@:
    60.           lods    byte [esi]
    61.           cmp     al,22h
    62.           je      @B
    63.           stos    byte [edi]
    64.           or      al,al
    65.           jnz     @B
    66.  
    67.           @@:
    68.           ; Проверяем, имеется или удаленное соединение
    69.           @call   [IsNetworkAlive],n_a_state
    70.           or      eax,eax
    71.           jnz     @F
    72.           ; Если соединения нет, ждем 1000 мс и повторяем проверку
    73.           @call   [Sleep],1000
    74.           jmp     @B
    75.           @@:
    76.           ; Выполняем скрипт (файл)
    77.           @call   [WinExec],bat_path,ebx
    78.  
    79.        exit:
    80.      .1:  @call   [ReleaseMutex],[h_mutex]
    81.      .2:  @call   [ExitProcess],ebx
    82. ;
    83. ; ###################################################################### ###
    84. ;
    85.   section '.idata' import data readable writeable
    86. ;
    87. ; ###################################################################### ###
    88. ;
    89.     library kernel32,'KERNEL32.DLL',\
    90.         sensapi,'SENSAPI.DLL'
    91.  
    92.     include '%fasminc%/apia/kernel32.inc'
    93.     include '%fasminc%/apia/sensapi.inc'
    94. ;
    95. ; ###################################################################### ###
    96. ;
    97.   section '.data' data readable writeable
    98. ;
    99. ; ###################################################################### ###
    100. ;
    101.  mutex_name   db 'RUNTLS_ALREADY_RUN_48957',0
    102.  kernel32_dll db 'kernel32.dll',0
    103.  krnl_func    db 'RegisterServiceProcess',0
    104.  n_a_state    dd 2
    105.  h_mutex      dd ?
    106.  bat_path     rb 1000h
    107. ;
    108.  
     
  9. q_q

    q_q New Member

    Blog Posts:
    0
    Joined:
    Oct 5, 2003
    Messages:
    1,706
    varnie

    MAPILogon возвращает в ЕАХе не нуль, а 2

    2 == MAPI_E_FAILURE - One or more unspecified errors occurred during logon. No session handle was returned.
     
  10. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    Исходник не компилится.

    Я с Fasm' ом не сильно, но что за файл

    include '%fasminc%/macro/fasm32.mac'

    у меня в дистрибе его нет (Fasm 1.57).

    И заодно, этот исходник работает со всеми соединениями?

    (диалап, vpn, adsl...)

    Спасибо.
     
  11. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    Кстати и include '%fasminc%/apia/sensapi.inc'

    тоже нет. Это стандартные или свои наработки?
     
  12. KiNDeR

    KiNDeR New Member

    Blog Posts:
    0
    Joined:
    Jun 13, 2003
    Messages:
    258
    Location:
    Russia
    Эти файлы - свои наработки, см.аттач.

    Я проверял на диалапе, локальной сетке, и xDSL модеме через циску...

    [​IMG] _1618399228__runtls.rar
     
  13. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    ОК!

    Все работает.

    БОЛЬШОЕ Спасибо.

    С функцией IsNetworkAlive еще не сталкивался,

    попробую покопать дальше.
     
  14. medal

    medal New Member

    Blog Posts:
    0
    Joined:
    Jan 20, 2005
    Messages:
    8
    Location:
    Russia
    Для надежности дописал проверку на IsDestinationReachable, и 100% проверка на Inet еnable!

    А то VPN other Ethernet не хотел видеть.

    Еще раз спасибо.
     
Thread Status:
Not open for further replies.