ホーム › Networking.WinInet › InternetGetConnectedState
InternetGetConnectedState
関数現在のインターネット接続状態を取得する。
シグネチャ
// WININET.dll
#include <windows.h>
BOOL InternetGetConnectedState(
INTERNET_CONNECTION* lpdwFlags,
DWORD dwReserved // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpdwFlags | INTERNET_CONNECTION* | out |
| dwReserved | DWORD | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll
#include <windows.h>
BOOL InternetGetConnectedState(
INTERNET_CONNECTION* lpdwFlags,
DWORD dwReserved // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", SetLastError = true, ExactSpelling = true)]
static extern bool InternetGetConnectedState(
out uint lpdwFlags, // INTERNET_CONNECTION* out
uint dwReserved // DWORD optional
);<DllImport("WININET.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetGetConnectedState(
<Out> ByRef lpdwFlags As UInteger, ' INTERNET_CONNECTION* out
dwReserved As UInteger ' DWORD optional
) As Boolean
End Function' lpdwFlags : INTERNET_CONNECTION* out
' dwReserved : DWORD optional
Declare PtrSafe Function InternetGetConnectedState Lib "wininet" ( _
ByRef lpdwFlags As Long, _
ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
InternetGetConnectedState = ctypes.windll.wininet.InternetGetConnectedState
InternetGetConnectedState.restype = wintypes.BOOL
InternetGetConnectedState.argtypes = [
ctypes.c_void_p, # lpdwFlags : INTERNET_CONNECTION* out
wintypes.DWORD, # dwReserved : DWORD optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
InternetGetConnectedState = Fiddle::Function.new(
lib['InternetGetConnectedState'],
[
Fiddle::TYPE_VOIDP, # lpdwFlags : INTERNET_CONNECTION* out
-Fiddle::TYPE_INT, # dwReserved : DWORD optional
],
Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn InternetGetConnectedState(
lpdwFlags: *mut u32, // INTERNET_CONNECTION* out
dwReserved: u32 // DWORD optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", SetLastError = true)]
public static extern bool InternetGetConnectedState(out uint lpdwFlags, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetGetConnectedState' -Namespace Win32 -PassThru
# $api::InternetGetConnectedState(lpdwFlags, dwReserved)#uselib "WININET.dll"
#func global InternetGetConnectedState "InternetGetConnectedState" sptr, sptr
; InternetGetConnectedState lpdwFlags, dwReserved ; 戻り値は stat
; lpdwFlags : INTERNET_CONNECTION* out -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global InternetGetConnectedState "InternetGetConnectedState" int, int
; res = InternetGetConnectedState(lpdwFlags, dwReserved)
; lpdwFlags : INTERNET_CONNECTION* out -> "int"
; dwReserved : DWORD optional -> "int"; BOOL InternetGetConnectedState(INTERNET_CONNECTION* lpdwFlags, DWORD dwReserved)
#uselib "WININET.dll"
#cfunc global InternetGetConnectedState "InternetGetConnectedState" int, int
; res = InternetGetConnectedState(lpdwFlags, dwReserved)
; lpdwFlags : INTERNET_CONNECTION* out -> "int"
; dwReserved : DWORD optional -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procInternetGetConnectedState = wininet.NewProc("InternetGetConnectedState")
)
// lpdwFlags (INTERNET_CONNECTION* out), dwReserved (DWORD optional)
r1, _, err := procInternetGetConnectedState.Call(
uintptr(lpdwFlags),
uintptr(dwReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetGetConnectedState(
lpdwFlags: Pointer; // INTERNET_CONNECTION* out
dwReserved: DWORD // DWORD optional
): BOOL; stdcall;
external 'WININET.dll' name 'InternetGetConnectedState';result := DllCall("WININET\InternetGetConnectedState"
, "Ptr", lpdwFlags ; INTERNET_CONNECTION* out
, "UInt", dwReserved ; DWORD optional
, "Int") ; return: BOOL●InternetGetConnectedState(lpdwFlags, dwReserved) = DLL("WININET.dll", "bool InternetGetConnectedState(void*, dword)")
# 呼び出し: InternetGetConnectedState(lpdwFlags, dwReserved)
# lpdwFlags : INTERNET_CONNECTION* out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。