URL_COMPONENTS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| dwStructSize | DWORD | 4 | +0 | +0 | この構造体のサイズ (バイト単位)。バージョンの確認に使用されます。この構造体を正しく初期化するには、この構造体のサイズを設定する必要があります。 | ||||||
| lpszScheme | LPWSTR | 8/4 | +8 | +4 | スキーム名を格納する文字列値へのポインター。 | ||||||
| dwSchemeLength | DWORD | 4 | +16 | +8 | スキーム名の長さ (文字単位)。 | ||||||
| nScheme | WINHTTP_INTERNET_SCHEME | 4 | +20 | +12 | インターネット プロトコルのスキーム。このメンバーには、次のいずれかの値を指定できます。
| ||||||
| lpszHostName | LPWSTR | 8/4 | +24 | +16 | ホスト名を格納する文字列値へのポインター。 | ||||||
| dwHostNameLength | DWORD | 4 | +32 | +20 | ホスト名の長さ (文字単位)。 | ||||||
| nPort | WORD | 2 | +36 | +24 | ポート番号。 | ||||||
| lpszUserName | LPWSTR | 8/4 | +40 | +28 | ユーザー名を格納する文字列へのポインター。 | ||||||
| dwUserNameLength | DWORD | 4 | +48 | +32 | ユーザー名の長さ (文字単位)。 | ||||||
| lpszPassword | LPWSTR | 8/4 | +56 | +36 | パスワードを格納する文字列へのポインター。 | ||||||
| dwPasswordLength | DWORD | 4 | +64 | +40 | パスワードの長さ (文字単位)。 | ||||||
| lpszUrlPath | LPWSTR | 8/4 | +72 | +44 | URL パスを格納する文字列へのポインター。 | ||||||
| dwUrlPathLength | DWORD | 4 | +80 | +48 | URL パスの長さ (文字単位)。 | ||||||
| lpszExtraInfo | LPWSTR | 8/4 | +88 | +52 | 追加情報 (たとえば ?something や #something) を格納する文字列値へのポインター。 | ||||||
| dwExtraInfoLength | DWORD | 4 | +96 | +56 | 追加情報の長さ (文字単位) を格納する符号なし long 整数値。 |
公式ドキュメント
URL_COMPONENTS 構造体は、URL を構成する各部分を格納します。この構造体は WinHttpCrackUrl 関数および WinHttpCreateUrl 関数で使用されます。
解説(Remarks)
WinHttpCrackUrl 関数の場合、ポインター メンバーと対応する長さメンバーが両方とも 0 のときは、その URL コンポーネントは返されません。ポインター メンバーが NULL で長さメンバーが 0 でない場合は、ポインター メンバーと長さメンバーの両方が返されます。ポインター メンバーと対応する長さメンバーの両方が 0 以外の場合、ポインター メンバーはコンポーネントのコピー先となるバッファーを指します。 WinHttpCrackUrl の dwFlags パラメーターによっては、コンポーネントからすべてのエスケープ シーケンスを削除できます。
WinHttpCreateUrl 関数の場合、その URL コンポーネントが不要であれば、ポインター メンバーを NULL にする必要があります。対応する長さメンバーが 0 の場合、ポインター メンバーは 0 で終わる文字列へのポインターです。長さメンバーが 0 でない場合、それは対応するポインター メンバーが指す文字列の長さを表します。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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