ホーム › Networking.WinHttp › URL_COMPONENTS
URL_COMPONENTS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwStructSize | DWORD | 4 | +0 | +0 | この構造体のバイト数。呼び出し前にsizeofで設定する。 |
| lpszScheme | LPWSTR | 8/4 | +8 | +4 | スキーム文字列(http等)を指す/格納するポインタ。NULL可。 |
| dwSchemeLength | DWORD | 4 | +16 | +8 | lpszSchemeの文字数。出力時は実際の長さを返す。 |
| nScheme | WINHTTP_INTERNET_SCHEME | 4 | +20 | +12 | スキーム種別を示す列挙値(WINHTTP_INTERNET_SCHEME)。HTTP/HTTPS等を表す。 |
| lpszHostName | LPWSTR | 8/4 | +24 | +16 | ホスト名文字列を指す/格納するポインタ。NULL可。 |
| dwHostNameLength | DWORD | 4 | +32 | +20 | lpszHostNameの文字数。 |
| nPort | WORD | 2 | +36 | +24 | ポート番号(WORD)。スキーム既定値が入る場合がある。 |
| lpszUserName | LPWSTR | 8/4 | +40 | +28 | URL中のユーザー名文字列を指す/格納するポインタ。NULL可。 |
| dwUserNameLength | DWORD | 4 | +48 | +32 | lpszUserNameの文字数。 |
| lpszPassword | LPWSTR | 8/4 | +56 | +36 | URL中のパスワード文字列を指す/格納するポインタ。NULL可。 |
| dwPasswordLength | DWORD | 4 | +64 | +40 | lpszPasswordの文字数。 |
| lpszUrlPath | LPWSTR | 8/4 | +72 | +44 | URLパス部分の文字列を指す/格納するポインタ。NULL可。 |
| dwUrlPathLength | DWORD | 4 | +80 | +48 | lpszUrlPathの文字数。 |
| lpszExtraInfo | LPWSTR | 8/4 | +88 | +52 | クエリやフラグメント等の付加情報文字列を指す/格納するポインタ。NULL可。 |
| dwExtraInfoLength | DWORD | 4 | +96 | +56 | lpszExtraInfoの文字数。 |
各言語での定義
#include <windows.h>
// URL_COMPONENTS (x64 104 / x86 60 バイト)
typedef struct URL_COMPONENTS {
DWORD dwStructSize;
LPWSTR lpszScheme;
DWORD dwSchemeLength;
WINHTTP_INTERNET_SCHEME nScheme;
LPWSTR lpszHostName;
DWORD dwHostNameLength;
WORD nPort;
LPWSTR lpszUserName;
DWORD dwUserNameLength;
LPWSTR lpszPassword;
DWORD dwPasswordLength;
LPWSTR lpszUrlPath;
DWORD dwUrlPathLength;
LPWSTR lpszExtraInfo;
DWORD dwExtraInfoLength;
} URL_COMPONENTS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct URL_COMPONENTS
{
public uint dwStructSize;
public IntPtr lpszScheme;
public uint dwSchemeLength;
public int nScheme;
public IntPtr lpszHostName;
public uint dwHostNameLength;
public ushort nPort;
public IntPtr lpszUserName;
public uint dwUserNameLength;
public IntPtr lpszPassword;
public uint dwPasswordLength;
public IntPtr lpszUrlPath;
public uint dwUrlPathLength;
public IntPtr lpszExtraInfo;
public uint dwExtraInfoLength;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure URL_COMPONENTS
Public dwStructSize As UInteger
Public lpszScheme As IntPtr
Public dwSchemeLength As UInteger
Public nScheme As Integer
Public lpszHostName As IntPtr
Public dwHostNameLength As UInteger
Public nPort As UShort
Public lpszUserName As IntPtr
Public dwUserNameLength As UInteger
Public lpszPassword As IntPtr
Public dwPasswordLength As UInteger
Public lpszUrlPath As IntPtr
Public dwUrlPathLength As UInteger
Public lpszExtraInfo As IntPtr
Public dwExtraInfoLength As UInteger
End Structureimport ctypes
from ctypes import wintypes
class URL_COMPONENTS(ctypes.Structure):
_fields_ = [
("dwStructSize", wintypes.DWORD),
("lpszScheme", ctypes.c_void_p),
("dwSchemeLength", wintypes.DWORD),
("nScheme", ctypes.c_int),
("lpszHostName", ctypes.c_void_p),
("dwHostNameLength", wintypes.DWORD),
("nPort", ctypes.c_ushort),
("lpszUserName", ctypes.c_void_p),
("dwUserNameLength", wintypes.DWORD),
("lpszPassword", ctypes.c_void_p),
("dwPasswordLength", wintypes.DWORD),
("lpszUrlPath", ctypes.c_void_p),
("dwUrlPathLength", wintypes.DWORD),
("lpszExtraInfo", ctypes.c_void_p),
("dwExtraInfoLength", wintypes.DWORD),
]#[repr(C)]
pub struct URL_COMPONENTS {
pub dwStructSize: u32,
pub lpszScheme: *mut core::ffi::c_void,
pub dwSchemeLength: u32,
pub nScheme: i32,
pub lpszHostName: *mut core::ffi::c_void,
pub dwHostNameLength: u32,
pub nPort: u16,
pub lpszUserName: *mut core::ffi::c_void,
pub dwUserNameLength: u32,
pub lpszPassword: *mut core::ffi::c_void,
pub dwPasswordLength: u32,
pub lpszUrlPath: *mut core::ffi::c_void,
pub dwUrlPathLength: u32,
pub lpszExtraInfo: *mut core::ffi::c_void,
pub dwExtraInfoLength: u32,
}import "golang.org/x/sys/windows"
type URL_COMPONENTS struct {
dwStructSize uint32
lpszScheme uintptr
dwSchemeLength uint32
nScheme int32
lpszHostName uintptr
dwHostNameLength uint32
nPort uint16
lpszUserName uintptr
dwUserNameLength uint32
lpszPassword uintptr
dwPasswordLength uint32
lpszUrlPath uintptr
dwUrlPathLength uint32
lpszExtraInfo uintptr
dwExtraInfoLength uint32
}type
URL_COMPONENTS = record
dwStructSize: DWORD;
lpszScheme: Pointer;
dwSchemeLength: DWORD;
nScheme: Integer;
lpszHostName: Pointer;
dwHostNameLength: DWORD;
nPort: Word;
lpszUserName: Pointer;
dwUserNameLength: DWORD;
lpszPassword: Pointer;
dwPasswordLength: DWORD;
lpszUrlPath: Pointer;
dwUrlPathLength: DWORD;
lpszExtraInfo: Pointer;
dwExtraInfoLength: DWORD;
end;const URL_COMPONENTS = extern struct {
dwStructSize: u32,
lpszScheme: ?*anyopaque,
dwSchemeLength: u32,
nScheme: i32,
lpszHostName: ?*anyopaque,
dwHostNameLength: u32,
nPort: u16,
lpszUserName: ?*anyopaque,
dwUserNameLength: u32,
lpszPassword: ?*anyopaque,
dwPasswordLength: u32,
lpszUrlPath: ?*anyopaque,
dwUrlPathLength: u32,
lpszExtraInfo: ?*anyopaque,
dwExtraInfoLength: u32,
};type
URL_COMPONENTS {.bycopy.} = object
dwStructSize: uint32
lpszScheme: pointer
dwSchemeLength: uint32
nScheme: int32
lpszHostName: pointer
dwHostNameLength: uint32
nPort: uint16
lpszUserName: pointer
dwUserNameLength: uint32
lpszPassword: pointer
dwPasswordLength: uint32
lpszUrlPath: pointer
dwUrlPathLength: uint32
lpszExtraInfo: pointer
dwExtraInfoLength: uint32struct URL_COMPONENTS
{
uint dwStructSize;
void* lpszScheme;
uint dwSchemeLength;
int nScheme;
void* lpszHostName;
uint dwHostNameLength;
ushort nPort;
void* lpszUserName;
uint dwUserNameLength;
void* lpszPassword;
uint dwPasswordLength;
void* lpszUrlPath;
uint dwUrlPathLength;
void* lpszExtraInfo;
uint dwExtraInfoLength;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; URL_COMPONENTS サイズ: 60 バイト(x86)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; dwStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpszScheme : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwSchemeLength : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; nScheme : WINHTTP_INTERNET_SCHEME (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpszHostName : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; dwHostNameLength : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; nPort : WORD (+24, 2byte) wpoke st,24,値 / 値 = wpeek(st,24)
; lpszUserName : LPWSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwUserNameLength : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; lpszPassword : LPWSTR (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwPasswordLength : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; lpszUrlPath : LPWSTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwUrlPathLength : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; lpszExtraInfo : LPWSTR (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; dwExtraInfoLength : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; URL_COMPONENTS サイズ: 104 バイト(x64)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; dwStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpszScheme : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; dwSchemeLength : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; nScheme : WINHTTP_INTERNET_SCHEME (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; lpszHostName : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; dwHostNameLength : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; nPort : WORD (+36, 2byte) wpoke st,36,値 / 値 = wpeek(st,36)
; lpszUserName : LPWSTR (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; dwUserNameLength : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; lpszPassword : LPWSTR (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; dwPasswordLength : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; lpszUrlPath : LPWSTR (+72, 8byte) qpoke st,72,値 / qpeek(st,72) ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; dwUrlPathLength : DWORD (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; lpszExtraInfo : LPWSTR (+88, 8byte) qpoke st,88,値 / qpeek(st,88) ※IronHSPのみ。3.7/3.8は lpoke st,88,下位 : lpoke st,92,上位
; dwExtraInfoLength : DWORD (+96, 4byte) st.24 = 値 / 値 = st.24 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global URL_COMPONENTS
#field int dwStructSize
#field intptr lpszScheme
#field int dwSchemeLength
#field int nScheme
#field intptr lpszHostName
#field int dwHostNameLength
#field short nPort
#field intptr lpszUserName
#field int dwUserNameLength
#field intptr lpszPassword
#field int dwPasswordLength
#field intptr lpszUrlPath
#field int dwUrlPathLength
#field intptr lpszExtraInfo
#field int dwExtraInfoLength
#endstruct
stdim st, URL_COMPONENTS ; NSTRUCT 変数を確保
st->dwStructSize = 100
mes "dwStructSize=" + st->dwStructSize