ホーム › Networking.WinInet › GopherGetLocatorTypeW
GopherGetLocatorTypeW
関数Gopherロケーターの種類を解析して取得する(Unicode版)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL GopherGetLocatorTypeW(
LPCWSTR lpszLocator,
DWORD* lpdwGopherType
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpszLocator | LPCWSTR | in | 解析する Gopher ロケータを指定する、null 終端文字列へのポインタです。 |
| lpdwGopherType | DWORD* | out | ロケータの種類を受け取る変数へのポインタです。種類は、 gopher type values の組み合わせから成るビットマスクです。 |
戻り値の型: BOOL
公式ドキュメント
Gopher ロケータを解析し、その属性を判定します。(Unicode)
戻り値
成功した場合は TRUE を、それ以外の場合は FALSE を返します。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
GopherGetLocatorType は、Gopher ロケータが参照する項目に関する情報を返します。1 つのファイルに複数の属性が設定される場合があることに注意してください。たとえば、Gopher+ サーバーに格納されたテキストファイルの場合、GOPHER_TYPE_TEXT_FILE と GOPHER_TYPE_GOPHER_PLUS の両方が設定されます。
WinINet API の他のすべての要素と同様に、この関数を DllMain 内、またはグローバルオブジェクトのコンストラクタやデストラクタ内から安全に呼び出すことはできません。
Note WinINet はサーバー実装をサポートしていません。また、サービスから使用すべきではありません。サーバー実装やサービスでは、Microsoft Windows HTTP Services (WinHTTP) を使用してください。
メモ
wininet.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして GopherGetLocatorType を定義します。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL GopherGetLocatorTypeW(
LPCWSTR lpszLocator,
DWORD* lpdwGopherType
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool GopherGetLocatorTypeW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszLocator, // LPCWSTR
out uint lpdwGopherType // DWORD* out
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GopherGetLocatorTypeW(
<MarshalAs(UnmanagedType.LPWStr)> lpszLocator As String, ' LPCWSTR
<Out> ByRef lpdwGopherType As UInteger ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' lpszLocator : LPCWSTR
' lpdwGopherType : DWORD* out
Declare PtrSafe Function GopherGetLocatorTypeW Lib "wininet" ( _
ByVal lpszLocator As LongPtr, _
ByRef lpdwGopherType As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GopherGetLocatorTypeW = ctypes.windll.wininet.GopherGetLocatorTypeW
GopherGetLocatorTypeW.restype = wintypes.BOOL
GopherGetLocatorTypeW.argtypes = [
wintypes.LPCWSTR, # lpszLocator : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # lpdwGopherType : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
GopherGetLocatorTypeW = Fiddle::Function.new(
lib['GopherGetLocatorTypeW'],
[
Fiddle::TYPE_VOIDP, # lpszLocator : LPCWSTR
Fiddle::TYPE_VOIDP, # lpdwGopherType : DWORD* out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn GopherGetLocatorTypeW(
lpszLocator: *const u16, // LPCWSTR
lpdwGopherType: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool GopherGetLocatorTypeW([MarshalAs(UnmanagedType.LPWStr)] string lpszLocator, out uint lpdwGopherType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherGetLocatorTypeW' -Namespace Win32 -PassThru
# $api::GopherGetLocatorTypeW(lpszLocator, lpdwGopherType)#uselib "WININET.dll"
#func global GopherGetLocatorTypeW "GopherGetLocatorTypeW" wptr, wptr
; GopherGetLocatorTypeW lpszLocator, varptr(lpdwGopherType) ; 戻り値は stat
; lpszLocator : LPCWSTR -> "wptr"
; lpdwGopherType : DWORD* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global GopherGetLocatorTypeW "GopherGetLocatorTypeW" wstr, var ; res = GopherGetLocatorTypeW(lpszLocator, lpdwGopherType) ; lpszLocator : LPCWSTR -> "wstr" ; lpdwGopherType : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global GopherGetLocatorTypeW "GopherGetLocatorTypeW" wstr, sptr ; res = GopherGetLocatorTypeW(lpszLocator, varptr(lpdwGopherType)) ; lpszLocator : LPCWSTR -> "wstr" ; lpdwGopherType : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GopherGetLocatorTypeW(LPCWSTR lpszLocator, DWORD* lpdwGopherType) #uselib "WININET.dll" #cfunc global GopherGetLocatorTypeW "GopherGetLocatorTypeW" wstr, var ; res = GopherGetLocatorTypeW(lpszLocator, lpdwGopherType) ; lpszLocator : LPCWSTR -> "wstr" ; lpdwGopherType : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GopherGetLocatorTypeW(LPCWSTR lpszLocator, DWORD* lpdwGopherType) #uselib "WININET.dll" #cfunc global GopherGetLocatorTypeW "GopherGetLocatorTypeW" wstr, intptr ; res = GopherGetLocatorTypeW(lpszLocator, varptr(lpdwGopherType)) ; lpszLocator : LPCWSTR -> "wstr" ; lpdwGopherType : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procGopherGetLocatorTypeW = wininet.NewProc("GopherGetLocatorTypeW")
)
// lpszLocator (LPCWSTR), lpdwGopherType (DWORD* out)
r1, _, err := procGopherGetLocatorTypeW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszLocator))),
uintptr(lpdwGopherType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GopherGetLocatorTypeW(
lpszLocator: PWideChar; // LPCWSTR
lpdwGopherType: Pointer // DWORD* out
): BOOL; stdcall;
external 'WININET.dll' name 'GopherGetLocatorTypeW';result := DllCall("WININET\GopherGetLocatorTypeW"
, "WStr", lpszLocator ; LPCWSTR
, "Ptr", lpdwGopherType ; DWORD* out
, "Int") ; return: BOOL●GopherGetLocatorTypeW(lpszLocator, lpdwGopherType) = DLL("WININET.dll", "bool GopherGetLocatorTypeW(char*, void*)")
# 呼び出し: GopherGetLocatorTypeW(lpszLocator, lpdwGopherType)
# lpszLocator : LPCWSTR -> "char*"
# lpdwGopherType : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "wininet" fn GopherGetLocatorTypeW(
lpszLocator: [*c]const u16, // LPCWSTR
lpdwGopherType: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc GopherGetLocatorTypeW(
lpszLocator: WideCString, # LPCWSTR
lpdwGopherType: ptr uint32 # DWORD* out
): int32 {.importc: "GopherGetLocatorTypeW", stdcall, dynlib: "WININET.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wininet");
extern(Windows)
int GopherGetLocatorTypeW(
const(wchar)* lpszLocator, // LPCWSTR
uint* lpdwGopherType // DWORD* out
);ccall((:GopherGetLocatorTypeW, "WININET.dll"), stdcall, Int32,
(Cwstring, Ptr{UInt32}),
lpszLocator, lpdwGopherType)
# lpszLocator : LPCWSTR -> Cwstring
# lpdwGopherType : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t GopherGetLocatorTypeW(
const uint16_t* lpszLocator,
uint32_t* lpdwGopherType);
]]
local wininet = ffi.load("wininet")
-- wininet.GopherGetLocatorTypeW(lpszLocator, lpdwGopherType)
-- lpszLocator : LPCWSTR
-- lpdwGopherType : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const GopherGetLocatorTypeW = lib.func('__stdcall', 'GopherGetLocatorTypeW', 'int32_t', ['str16', 'uint32_t *']);
// GopherGetLocatorTypeW(lpszLocator, lpdwGopherType)
// lpszLocator : LPCWSTR -> 'str16'
// lpdwGopherType : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
GopherGetLocatorTypeW: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.GopherGetLocatorTypeW(lpszLocator, lpdwGopherType)
// lpszLocator : LPCWSTR -> "buffer"
// lpdwGopherType : DWORD* out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GopherGetLocatorTypeW(
const uint16_t* lpszLocator,
uint32_t* lpdwGopherType);
C, "WININET.dll");
// $ffi->GopherGetLocatorTypeW(lpszLocator, lpdwGopherType);
// lpszLocator : LPCWSTR
// lpdwGopherType : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.UNICODE_OPTIONS);
boolean GopherGetLocatorTypeW(
WString lpszLocator, // LPCWSTR
IntByReference lpdwGopherType // DWORD* out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wininet")]
lib LibWININET
fun GopherGetLocatorTypeW = GopherGetLocatorTypeW(
lpszLocator : UInt16*, # LPCWSTR
lpdwGopherType : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GopherGetLocatorTypeWNative = Int32 Function(Pointer<Utf16>, Pointer<Uint32>);
typedef GopherGetLocatorTypeWDart = int Function(Pointer<Utf16>, Pointer<Uint32>);
final GopherGetLocatorTypeW = DynamicLibrary.open('WININET.dll')
.lookupFunction<GopherGetLocatorTypeWNative, GopherGetLocatorTypeWDart>('GopherGetLocatorTypeW');
// lpszLocator : LPCWSTR -> Pointer<Utf16>
// lpdwGopherType : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GopherGetLocatorTypeW(
lpszLocator: PWideChar; // LPCWSTR
lpdwGopherType: Pointer // DWORD* out
): BOOL; stdcall;
external 'WININET.dll' name 'GopherGetLocatorTypeW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GopherGetLocatorTypeW"
c_GopherGetLocatorTypeW :: CWString -> Ptr Word32 -> IO CInt
-- lpszLocator : LPCWSTR -> CWString
-- lpdwGopherType : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gophergetlocatortypew =
foreign "GopherGetLocatorTypeW"
((ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* lpszLocator : LPCWSTR -> (ptr uint16_t) *)
(* lpdwGopherType : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("GopherGetLocatorTypeW" gopher-get-locator-type-w :convention :stdcall) :int32
(lpsz-locator (:string :encoding :utf-16le)) ; LPCWSTR
(lpdw-gopher-type :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GopherGetLocatorTypeW = Win32::API::More->new('WININET',
'BOOL GopherGetLocatorTypeW(LPCWSTR lpszLocator, LPVOID lpdwGopherType)');
# my $ret = $GopherGetLocatorTypeW->Call($lpszLocator, $lpdwGopherType);
# lpszLocator : LPCWSTR -> LPCWSTR
# lpdwGopherType : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f GopherGetLocatorTypeA (ANSI版) — Gopherロケーターの種類を解析して取得する(ANSI版)。