Win32 API 日本語リファレンス
ホームNetworking.WinInet › GopherGetLocatorTypeA

GopherGetLocatorTypeA

関数
Gopherロケーターの種類を解析して取得する(ANSI版)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL GopherGetLocatorTypeA(
    LPCSTR lpszLocator,
    DWORD* lpdwGopherType
);

パラメーター

名前方向説明
lpszLocatorLPCSTRin解析する Gopher ロケーターを指定する、null で終わる文字列へのポインター。
lpdwGopherTypeDWORD*outロケーターの種類を受け取る変数へのポインター。種類は、 gopher type values の組み合わせから成るビットマスクです。

戻り値の型: BOOL

公式ドキュメント

Gopher ロケーターを解析し、その属性を判別します。(ANSI)

戻り値

成功した場合は TRUE を、それ以外の場合は FALSE を返します。拡張エラー情報を取得するには、 GetLastError を呼び出します。

解説(Remarks)

GopherGetLocatorType は、Gopher ロケーターが参照する項目に関する情報を返します。1 つのファイルに複数の属性が設定される場合があることに注意してください。たとえば、Gopher+ サーバーに格納されたテキストファイルには、GOPHER_TYPE_TEXT_FILEGOPHER_TYPE_GOPHER_PLUS の両方が設定されます。

WinINet API の他のすべての要素と同様に、この関数を DllMain 内や、グローバルオブジェクトのコンストラクター/デストラクター内から安全に呼び出すことはできません。

Note WinINet はサーバー実装をサポートしていません。また、サービスから使用すべきではありません。サーバー実装やサービスには、Microsoft Windows HTTP Services (WinHTTP) を使用してください。
メモ

wininet.h ヘッダーは、GopherGetLocatorType を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスの使用を、エンコーディング非依存でないコードと混在させると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL GopherGetLocatorTypeA(
    LPCSTR lpszLocator,
    DWORD* lpdwGopherType
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GopherGetLocatorTypeA(
    [MarshalAs(UnmanagedType.LPStr)] string lpszLocator,   // LPCSTR
    out uint lpdwGopherType   // DWORD* out
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GopherGetLocatorTypeA(
    <MarshalAs(UnmanagedType.LPStr)> lpszLocator As String,   ' LPCSTR
    <Out> ByRef lpdwGopherType As UInteger   ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' lpszLocator : LPCSTR
' lpdwGopherType : DWORD* out
Declare PtrSafe Function GopherGetLocatorTypeA Lib "wininet" ( _
    ByVal lpszLocator As String, _
    ByRef lpdwGopherType As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GopherGetLocatorTypeA = ctypes.windll.wininet.GopherGetLocatorTypeA
GopherGetLocatorTypeA.restype = wintypes.BOOL
GopherGetLocatorTypeA.argtypes = [
    wintypes.LPCSTR,  # lpszLocator : LPCSTR
    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')
GopherGetLocatorTypeA = Fiddle::Function.new(
  lib['GopherGetLocatorTypeA'],
  [
    Fiddle::TYPE_VOIDP,  # lpszLocator : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpdwGopherType : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn GopherGetLocatorTypeA(
        lpszLocator: *const u8,  // LPCSTR
        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.Ansi, SetLastError = true)]
public static extern bool GopherGetLocatorTypeA([MarshalAs(UnmanagedType.LPStr)] string lpszLocator, out uint lpdwGopherType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherGetLocatorTypeA' -Namespace Win32 -PassThru
# $api::GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
#uselib "WININET.dll"
#func global GopherGetLocatorTypeA "GopherGetLocatorTypeA" sptr, sptr
; GopherGetLocatorTypeA lpszLocator, varptr(lpdwGopherType)   ; 戻り値は stat
; lpszLocator : LPCSTR -> "sptr"
; lpdwGopherType : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global GopherGetLocatorTypeA "GopherGetLocatorTypeA" str, var
; res = GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
; lpszLocator : LPCSTR -> "str"
; lpdwGopherType : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GopherGetLocatorTypeA(LPCSTR lpszLocator, DWORD* lpdwGopherType)
#uselib "WININET.dll"
#cfunc global GopherGetLocatorTypeA "GopherGetLocatorTypeA" str, var
; res = GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
; lpszLocator : LPCSTR -> "str"
; lpdwGopherType : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procGopherGetLocatorTypeA = wininet.NewProc("GopherGetLocatorTypeA")
)

// lpszLocator (LPCSTR), lpdwGopherType (DWORD* out)
r1, _, err := procGopherGetLocatorTypeA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszLocator))),
	uintptr(lpdwGopherType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GopherGetLocatorTypeA(
  lpszLocator: PAnsiChar;   // LPCSTR
  lpdwGopherType: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'WININET.dll' name 'GopherGetLocatorTypeA';
result := DllCall("WININET\GopherGetLocatorTypeA"
    , "AStr", lpszLocator   ; LPCSTR
    , "Ptr", lpdwGopherType   ; DWORD* out
    , "Int")   ; return: BOOL
●GopherGetLocatorTypeA(lpszLocator, lpdwGopherType) = DLL("WININET.dll", "bool GopherGetLocatorTypeA(char*, void*)")
# 呼び出し: GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
# lpszLocator : LPCSTR -> "char*"
# lpdwGopherType : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wininet" fn GopherGetLocatorTypeA(
    lpszLocator: [*c]const u8, // LPCSTR
    lpdwGopherType: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
proc GopherGetLocatorTypeA(
    lpszLocator: cstring,  # LPCSTR
    lpdwGopherType: ptr uint32  # DWORD* out
): int32 {.importc: "GopherGetLocatorTypeA", stdcall, dynlib: "WININET.dll".}
pragma(lib, "wininet");
extern(Windows)
int GopherGetLocatorTypeA(
    const(char)* lpszLocator,   // LPCSTR
    uint* lpdwGopherType   // DWORD* out
);
ccall((:GopherGetLocatorTypeA, "WININET.dll"), stdcall, Int32,
      (Cstring, Ptr{UInt32}),
      lpszLocator, lpdwGopherType)
# lpszLocator : LPCSTR -> Cstring
# lpdwGopherType : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GopherGetLocatorTypeA(
    const char* lpszLocator,
    uint32_t* lpdwGopherType);
]]
local wininet = ffi.load("wininet")
-- wininet.GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
-- lpszLocator : LPCSTR
-- lpdwGopherType : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const GopherGetLocatorTypeA = lib.func('__stdcall', 'GopherGetLocatorTypeA', 'int32_t', ['str', 'uint32_t *']);
// GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
// lpszLocator : LPCSTR -> 'str'
// lpdwGopherType : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WININET.dll", {
  GopherGetLocatorTypeA: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.GopherGetLocatorTypeA(lpszLocator, lpdwGopherType)
// lpszLocator : LPCSTR -> "buffer"
// lpdwGopherType : DWORD* out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GopherGetLocatorTypeA(
    const char* lpszLocator,
    uint32_t* lpdwGopherType);
C, "WININET.dll");
// $ffi->GopherGetLocatorTypeA(lpszLocator, lpdwGopherType);
// lpszLocator : LPCSTR
// 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.ASCII_OPTIONS);
    boolean GopherGetLocatorTypeA(
        String lpszLocator,   // LPCSTR
        IntByReference lpdwGopherType   // DWORD* out
    );
}
@[Link("wininet")]
lib LibWININET
  fun GopherGetLocatorTypeA = GopherGetLocatorTypeA(
    lpszLocator : UInt8*,   # LPCSTR
    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 GopherGetLocatorTypeANative = Int32 Function(Pointer<Utf8>, Pointer<Uint32>);
typedef GopherGetLocatorTypeADart = int Function(Pointer<Utf8>, Pointer<Uint32>);
final GopherGetLocatorTypeA = DynamicLibrary.open('WININET.dll')
    .lookupFunction<GopherGetLocatorTypeANative, GopherGetLocatorTypeADart>('GopherGetLocatorTypeA');
// lpszLocator : LPCSTR -> Pointer<Utf8>
// lpdwGopherType : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GopherGetLocatorTypeA(
  lpszLocator: PAnsiChar;   // LPCSTR
  lpdwGopherType: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'WININET.dll' name 'GopherGetLocatorTypeA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GopherGetLocatorTypeA"
  c_GopherGetLocatorTypeA :: CString -> Ptr Word32 -> IO CInt
-- lpszLocator : LPCSTR -> CString
-- lpdwGopherType : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gophergetlocatortypea =
  foreign "GopherGetLocatorTypeA"
    (string @-> (ptr uint32_t) @-> returning int32_t)
(* lpszLocator : LPCSTR -> string *)
(* 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 ("GopherGetLocatorTypeA" gopher-get-locator-type-a :convention :stdcall) :int32
  (lpsz-locator :string)   ; LPCSTR
  (lpdw-gopher-type :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GopherGetLocatorTypeA = Win32::API::More->new('WININET',
    'BOOL GopherGetLocatorTypeA(LPCSTR lpszLocator, LPVOID lpdwGopherType)');
# my $ret = $GopherGetLocatorTypeA->Call($lpszLocator, $lpdwGopherType);
# lpszLocator : LPCSTR -> LPCSTR
# lpdwGopherType : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い