URL_COMPONENTSW
構造体サイズ=各フィールドのバイト数(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 | スキーム名のサイズ (TCHARs 単位)。 |
| nScheme | INTERNET_SCHEME | 4 | +20 | +12 | インターネットプロトコルのスキームを示す INTERNET_SCHEME 値。 |
| lpszHostName | LPWSTR | 8/4 | +24 | +16 | ホスト名を格納する文字列へのポインター。 |
| dwHostNameLength | DWORD | 4 | +32 | +20 | ホスト名のサイズ (TCHARs 単位)。 |
| nPort | WORD | 2 | +36 | +24 | 変換されたポート番号。 |
| lpszUserName | LPWSTR | 8/4 | +40 | +28 | ユーザー名を格納する文字列値へのポインター。 |
| dwUserNameLength | DWORD | 4 | +48 | +32 | ユーザー名のサイズ (TCHARs 単位)。 |
| lpszPassword | LPWSTR | 8/4 | +56 | +36 | パスワードを格納する文字列へのポインター。 |
| dwPasswordLength | DWORD | 4 | +64 | +40 | パスワードのサイズ (TCHARs 単位)。 |
| lpszUrlPath | LPWSTR | 8/4 | +72 | +44 | URL パスを格納する文字列へのポインター。 |
| dwUrlPathLength | DWORD | 4 | +80 | +48 | URL パスのサイズ (TCHARs 単位)。 |
| lpszExtraInfo | LPWSTR | 8/4 | +88 | +52 | 追加情報 (たとえば ?something や #something) を格納する文字列へのポインター。 |
| dwExtraInfoLength | DWORD | 4 | +96 | +56 | 追加情報のサイズ (TCHARs 単位)。 |
公式ドキュメント
URL の構成要素を格納します。この構造体は InternetCrackUrl 関数および InternetCreateUrl 関数で使用されます。
解説(Remarks)
InternetCrackUrl の場合、ポインターメンバーとそれに対応する長さメンバーが両方とも 0 であれば、そのコンポーネントは返されません。ポインターメンバーが NULL で長さメンバーが 0 でない場合は、ポインターと長さの両方のメンバーが返されます。ポインターメンバーと対応する長さメンバーが両方とも 0 以外の場合、ポインターメンバーはコンポーネントのコピー先となるバッファーを指します。コンポーネントは、 InternetCrackUrl の dwFlags パラメーターに応じてエスケープ解除されることがあります。
InternetCreateUrl の場合、コンポーネントが不要であればポインターメンバーは NULL でなければなりません。対応する長さメンバーが 0 の場合、ポインターメンバーは 0 で終わる文字列のアドレスです。長さメンバーが 0 でない場合、その値は対応するポインターメンバーの文字列長です。
wininet.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして URL_COMPONENTS を定義します。エンコーディング非依存のエイリアスと、エンコーディング非依存でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、関数プロトタイプの規則 を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// URL_COMPONENTSW (x64 104 / x86 60 バイト)
typedef struct URL_COMPONENTSW {
DWORD dwStructSize;
LPWSTR lpszScheme;
DWORD dwSchemeLength;
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_COMPONENTSW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct URL_COMPONENTSW
{
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_COMPONENTSW
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_COMPONENTSW(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_COMPONENTSW {
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_COMPONENTSW 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_COMPONENTSW = 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_COMPONENTSW = 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_COMPONENTSW {.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_COMPONENTSW
{
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_COMPONENTSW サイズ: 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 : 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_COMPONENTSW サイズ: 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 : 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_COMPONENTSW
#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_COMPONENTSW ; NSTRUCT 変数を確保
st->dwStructSize = 100
mes "dwStructSize=" + st->dwStructSize