Win32 API 日本語リファレンス
ホームNetworking.WinInet › INTERNET_CREDENTIALS

INTERNET_CREDENTIALS

構造体
サイズx64: 48 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
lpcwszHostNameLPWSTR8/4+0+0認証対象のホスト名文字列である。
dwPortDWORD4+8+4認証対象のポート番号である。
dwSchemeDWORD4+12+8認証スキームを示す値である。Basic/NTLM等。
lpcwszUrlLPWSTR8/4+16+12認証対象のURL文字列である。NULL可。
lpcwszRealmLPWSTR8/4+24+16認証レルム(領域)を示す文字列である。NULL可。
fAuthIdentityBOOL4+32+20資格情報がID形式で指定されているかを示す真偽値である。
Anonymous_Anonymous_e__Union8/4+40+24ユーザ名/パスワードまたは資格情報ハンドルを格納する無名共用体である。

共用体: _Anonymous_e__Union x64 8B / x86 4B

フィールドサイズx64x86説明
Anonymous_Anonymous_e__Struct8/4+0+0ユーザ名/パスワードまたは資格情報ハンドルを格納する無名共用体である。
pAuthIdentityOpaquevoid*8/4+0+0

各言語での定義

#include <windows.h>

// INTERNET_CREDENTIALS  (x64 48 / x86 28 バイト)
typedef struct INTERNET_CREDENTIALS {
    LPWSTR lpcwszHostName;
    DWORD dwPort;
    DWORD dwScheme;
    LPWSTR lpcwszUrl;
    LPWSTR lpcwszRealm;
    BOOL fAuthIdentity;
    _Anonymous_e__Union Anonymous;
} INTERNET_CREDENTIALS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INTERNET_CREDENTIALS
{
    public IntPtr lpcwszHostName;
    public uint dwPort;
    public uint dwScheme;
    public IntPtr lpcwszUrl;
    public IntPtr lpcwszRealm;
    [MarshalAs(UnmanagedType.Bool)] public bool fAuthIdentity;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INTERNET_CREDENTIALS
    Public lpcwszHostName As IntPtr
    Public dwPort As UInteger
    Public dwScheme As UInteger
    Public lpcwszUrl As IntPtr
    Public lpcwszRealm As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public fAuthIdentity As Boolean
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class INTERNET_CREDENTIALS(ctypes.Structure):
    _fields_ = [
        ("lpcwszHostName", ctypes.c_void_p),
        ("dwPort", wintypes.DWORD),
        ("dwScheme", wintypes.DWORD),
        ("lpcwszUrl", ctypes.c_void_p),
        ("lpcwszRealm", ctypes.c_void_p),
        ("fAuthIdentity", wintypes.BOOL),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct INTERNET_CREDENTIALS {
    pub lpcwszHostName: *mut core::ffi::c_void,
    pub dwPort: u32,
    pub dwScheme: u32,
    pub lpcwszUrl: *mut core::ffi::c_void,
    pub lpcwszRealm: *mut core::ffi::c_void,
    pub fAuthIdentity: i32,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type INTERNET_CREDENTIALS struct {
	lpcwszHostName uintptr
	dwPort uint32
	dwScheme uint32
	lpcwszUrl uintptr
	lpcwszRealm uintptr
	fAuthIdentity int32
	Anonymous _Anonymous_e__Union
}
type
  INTERNET_CREDENTIALS = record
    lpcwszHostName: Pointer;
    dwPort: DWORD;
    dwScheme: DWORD;
    lpcwszUrl: Pointer;
    lpcwszRealm: Pointer;
    fAuthIdentity: BOOL;
    Anonymous: _Anonymous_e__Union;
  end;
const INTERNET_CREDENTIALS = extern struct {
    lpcwszHostName: ?*anyopaque,
    dwPort: u32,
    dwScheme: u32,
    lpcwszUrl: ?*anyopaque,
    lpcwszRealm: ?*anyopaque,
    fAuthIdentity: i32,
    Anonymous: _Anonymous_e__Union,
};
type
  INTERNET_CREDENTIALS {.bycopy.} = object
    lpcwszHostName: pointer
    dwPort: uint32
    dwScheme: uint32
    lpcwszUrl: pointer
    lpcwszRealm: pointer
    fAuthIdentity: int32
    Anonymous: _Anonymous_e__Union
struct INTERNET_CREDENTIALS
{
    void* lpcwszHostName;
    uint dwPort;
    uint dwScheme;
    void* lpcwszUrl;
    void* lpcwszRealm;
    int fAuthIdentity;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; INTERNET_CREDENTIALS サイズ: 28 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; lpcwszHostName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwPort : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwScheme : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; lpcwszUrl : LPWSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; lpcwszRealm : LPWSTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; fAuthIdentity : BOOL (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INTERNET_CREDENTIALS サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; lpcwszHostName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; dwPort : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwScheme : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; lpcwszUrl : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpcwszRealm : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; fAuthIdentity : BOOL (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global INTERNET_CREDENTIALS
    #field intptr lpcwszHostName
    #field int dwPort
    #field int dwScheme
    #field intptr lpcwszUrl
    #field intptr lpcwszRealm
    #field bool fAuthIdentity
    #field byte Anonymous 8
#endstruct

stdim st, INTERNET_CREDENTIALS        ; NSTRUCT 変数を確保
st->dwPort = 100
mes "dwPort=" + st->dwPort
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。