URL_COMPONENTSA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwStructSize | DWORD | 4 | +0 | +0 | この構造体のサイズ (バイト単位)。 |
| lpszScheme | LPSTR | 8/4 | +8 | +4 | スキーム名を格納する文字列へのポインターです。 |
| dwSchemeLength | DWORD | 4 | +16 | +8 | スキーム名のサイズ (TCHARs 単位)。 |
| nScheme | INTERNET_SCHEME | 4 | +20 | +12 | インターネットプロトコルのスキームを示す INTERNET_SCHEME 値です。 |
| lpszHostName | LPSTR | 8/4 | +24 | +16 | ホスト名を格納する文字列へのポインターです。 |
| dwHostNameLength | DWORD | 4 | +32 | +20 | ホスト名のサイズ (TCHARs 単位)。 |
| nPort | WORD | 2 | +36 | +24 | 変換後のポート番号です。 |
| lpszUserName | LPSTR | 8/4 | +40 | +28 | ユーザー名を格納する文字列値へのポインターです。 |
| dwUserNameLength | DWORD | 4 | +48 | +32 | ユーザー名のサイズ (TCHARs 単位)。 |
| lpszPassword | LPSTR | 8/4 | +56 | +36 | パスワードを格納する文字列へのポインターです。 |
| dwPasswordLength | DWORD | 4 | +64 | +40 | パスワードのサイズ (TCHARs 単位)。 |
| lpszUrlPath | LPSTR | 8/4 | +72 | +44 | URL パスを格納する文字列へのポインターです。 |
| dwUrlPathLength | DWORD | 4 | +80 | +48 | URL パスのサイズ (TCHARs 単位)。 |
| lpszExtraInfo | LPSTR | 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 ヘッダーは URL_COMPONENTS を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因になることがあります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// URL_COMPONENTSA (x64 104 / x86 60 バイト)
typedef struct URL_COMPONENTSA {
DWORD dwStructSize;
LPSTR lpszScheme;
DWORD dwSchemeLength;
INTERNET_SCHEME nScheme;
LPSTR lpszHostName;
DWORD dwHostNameLength;
WORD nPort;
LPSTR lpszUserName;
DWORD dwUserNameLength;
LPSTR lpszPassword;
DWORD dwPasswordLength;
LPSTR lpszUrlPath;
DWORD dwUrlPathLength;
LPSTR lpszExtraInfo;
DWORD dwExtraInfoLength;
} URL_COMPONENTSA;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct URL_COMPONENTSA
{
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_COMPONENTSA
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_COMPONENTSA(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_COMPONENTSA {
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_COMPONENTSA 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_COMPONENTSA = 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_COMPONENTSA = 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_COMPONENTSA {.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_COMPONENTSA
{
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_COMPONENTSA サイズ: 60 バイト(x86)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; dwStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpszScheme : LPSTR (+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 : LPSTR (+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 : LPSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwUserNameLength : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; lpszPassword : LPSTR (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwPasswordLength : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; lpszUrlPath : LPSTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwUrlPathLength : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; lpszExtraInfo : LPSTR (+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_COMPONENTSA サイズ: 104 バイト(x64)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; dwStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; lpszScheme : LPSTR (+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 : LPSTR (+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 : LPSTR (+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 : LPSTR (+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 : LPSTR (+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 : LPSTR (+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_COMPONENTSA
#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_COMPONENTSA ; NSTRUCT 変数を確保
st->dwStructSize = 100
mes "dwStructSize=" + st->dwStructSize