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

GopherCreateLocatorW

関数
指定要素からGopherロケーター文字列を生成する(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL GopherCreateLocatorW(
    LPCWSTR lpszHost,
    WORD nServerPort,
    LPCWSTR lpszDisplayString,   // optional
    LPCWSTR lpszSelectorString,   // optional
    DWORD dwGopherType,
    LPWSTR lpszLocator,   // optional
    DWORD* lpdwBufferLength
);

パラメーター

名前方向
lpszHostLPCWSTRin
nServerPortWORDin
lpszDisplayStringLPCWSTRinoptional
lpszSelectorStringLPCWSTRinoptional
dwGopherTypeDWORDin
lpszLocatorLPWSTRoutoptional
lpdwBufferLengthDWORD*inout

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL GopherCreateLocatorW(
    LPCWSTR lpszHost,
    WORD nServerPort,
    LPCWSTR lpszDisplayString,   // optional
    LPCWSTR lpszSelectorString,   // optional
    DWORD dwGopherType,
    LPWSTR lpszLocator,   // optional
    DWORD* lpdwBufferLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool GopherCreateLocatorW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpszHost,   // LPCWSTR
    ushort nServerPort,   // WORD
    [MarshalAs(UnmanagedType.LPWStr)] string lpszDisplayString,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string lpszSelectorString,   // LPCWSTR optional
    uint dwGopherType,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszLocator,   // LPWSTR optional, out
    ref uint lpdwBufferLength   // DWORD* in/out
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GopherCreateLocatorW(
    <MarshalAs(UnmanagedType.LPWStr)> lpszHost As String,   ' LPCWSTR
    nServerPort As UShort,   ' WORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszDisplayString As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> lpszSelectorString As String,   ' LPCWSTR optional
    dwGopherType As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszLocator As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef lpdwBufferLength As UInteger   ' DWORD* in/out
) As Boolean
End Function
' lpszHost : LPCWSTR
' nServerPort : WORD
' lpszDisplayString : LPCWSTR optional
' lpszSelectorString : LPCWSTR optional
' dwGopherType : DWORD
' lpszLocator : LPWSTR optional, out
' lpdwBufferLength : DWORD* in/out
Declare PtrSafe Function GopherCreateLocatorW Lib "wininet" ( _
    ByVal lpszHost As LongPtr, _
    ByVal nServerPort As Integer, _
    ByVal lpszDisplayString As LongPtr, _
    ByVal lpszSelectorString As LongPtr, _
    ByVal dwGopherType As Long, _
    ByVal lpszLocator As LongPtr, _
    ByRef lpdwBufferLength 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

GopherCreateLocatorW = ctypes.windll.wininet.GopherCreateLocatorW
GopherCreateLocatorW.restype = wintypes.BOOL
GopherCreateLocatorW.argtypes = [
    wintypes.LPCWSTR,  # lpszHost : LPCWSTR
    ctypes.c_ushort,  # nServerPort : WORD
    wintypes.LPCWSTR,  # lpszDisplayString : LPCWSTR optional
    wintypes.LPCWSTR,  # lpszSelectorString : LPCWSTR optional
    wintypes.DWORD,  # dwGopherType : DWORD
    wintypes.LPWSTR,  # lpszLocator : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufferLength : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
GopherCreateLocatorW = Fiddle::Function.new(
  lib['GopherCreateLocatorW'],
  [
    Fiddle::TYPE_VOIDP,  # lpszHost : LPCWSTR
    -Fiddle::TYPE_SHORT,  # nServerPort : WORD
    Fiddle::TYPE_VOIDP,  # lpszDisplayString : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # lpszSelectorString : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwGopherType : DWORD
    Fiddle::TYPE_VOIDP,  # lpszLocator : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # lpdwBufferLength : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn GopherCreateLocatorW(
        lpszHost: *const u16,  // LPCWSTR
        nServerPort: u16,  // WORD
        lpszDisplayString: *const u16,  // LPCWSTR optional
        lpszSelectorString: *const u16,  // LPCWSTR optional
        dwGopherType: u32,  // DWORD
        lpszLocator: *mut u16,  // LPWSTR optional, out
        lpdwBufferLength: *mut u32  // DWORD* in/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 GopherCreateLocatorW([MarshalAs(UnmanagedType.LPWStr)] string lpszHost, ushort nServerPort, [MarshalAs(UnmanagedType.LPWStr)] string lpszDisplayString, [MarshalAs(UnmanagedType.LPWStr)] string lpszSelectorString, uint dwGopherType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszLocator, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherCreateLocatorW' -Namespace Win32 -PassThru
# $api::GopherCreateLocatorW(lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, lpszLocator, lpdwBufferLength)
#uselib "WININET.dll"
#func global GopherCreateLocatorW "GopherCreateLocatorW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; GopherCreateLocatorW lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, varptr(lpszLocator), varptr(lpdwBufferLength)   ; 戻り値は stat
; lpszHost : LPCWSTR -> "wptr"
; nServerPort : WORD -> "wptr"
; lpszDisplayString : LPCWSTR optional -> "wptr"
; lpszSelectorString : LPCWSTR optional -> "wptr"
; dwGopherType : DWORD -> "wptr"
; lpszLocator : LPWSTR optional, out -> "wptr"
; lpdwBufferLength : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global GopherCreateLocatorW "GopherCreateLocatorW" wstr, int, wstr, wstr, int, var, var
; res = GopherCreateLocatorW(lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, lpszLocator, lpdwBufferLength)
; lpszHost : LPCWSTR -> "wstr"
; nServerPort : WORD -> "int"
; lpszDisplayString : LPCWSTR optional -> "wstr"
; lpszSelectorString : LPCWSTR optional -> "wstr"
; dwGopherType : DWORD -> "int"
; lpszLocator : LPWSTR optional, out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GopherCreateLocatorW(LPCWSTR lpszHost, WORD nServerPort, LPCWSTR lpszDisplayString, LPCWSTR lpszSelectorString, DWORD dwGopherType, LPWSTR lpszLocator, DWORD* lpdwBufferLength)
#uselib "WININET.dll"
#cfunc global GopherCreateLocatorW "GopherCreateLocatorW" wstr, int, wstr, wstr, int, var, var
; res = GopherCreateLocatorW(lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, lpszLocator, lpdwBufferLength)
; lpszHost : LPCWSTR -> "wstr"
; nServerPort : WORD -> "int"
; lpszDisplayString : LPCWSTR optional -> "wstr"
; lpszSelectorString : LPCWSTR optional -> "wstr"
; dwGopherType : DWORD -> "int"
; lpszLocator : LPWSTR optional, out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procGopherCreateLocatorW = wininet.NewProc("GopherCreateLocatorW")
)

// lpszHost (LPCWSTR), nServerPort (WORD), lpszDisplayString (LPCWSTR optional), lpszSelectorString (LPCWSTR optional), dwGopherType (DWORD), lpszLocator (LPWSTR optional, out), lpdwBufferLength (DWORD* in/out)
r1, _, err := procGopherCreateLocatorW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszHost))),
	uintptr(nServerPort),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDisplayString))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSelectorString))),
	uintptr(dwGopherType),
	uintptr(lpszLocator),
	uintptr(lpdwBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GopherCreateLocatorW(
  lpszHost: PWideChar;   // LPCWSTR
  nServerPort: Word;   // WORD
  lpszDisplayString: PWideChar;   // LPCWSTR optional
  lpszSelectorString: PWideChar;   // LPCWSTR optional
  dwGopherType: DWORD;   // DWORD
  lpszLocator: PWideChar;   // LPWSTR optional, out
  lpdwBufferLength: Pointer   // DWORD* in/out
): BOOL; stdcall;
  external 'WININET.dll' name 'GopherCreateLocatorW';
result := DllCall("WININET\GopherCreateLocatorW"
    , "WStr", lpszHost   ; LPCWSTR
    , "UShort", nServerPort   ; WORD
    , "WStr", lpszDisplayString   ; LPCWSTR optional
    , "WStr", lpszSelectorString   ; LPCWSTR optional
    , "UInt", dwGopherType   ; DWORD
    , "Ptr", lpszLocator   ; LPWSTR optional, out
    , "Ptr", lpdwBufferLength   ; DWORD* in/out
    , "Int")   ; return: BOOL
●GopherCreateLocatorW(lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, lpszLocator, lpdwBufferLength) = DLL("WININET.dll", "bool GopherCreateLocatorW(char*, int, char*, char*, dword, char*, void*)")
# 呼び出し: GopherCreateLocatorW(lpszHost, nServerPort, lpszDisplayString, lpszSelectorString, dwGopherType, lpszLocator, lpdwBufferLength)
# lpszHost : LPCWSTR -> "char*"
# nServerPort : WORD -> "int"
# lpszDisplayString : LPCWSTR optional -> "char*"
# lpszSelectorString : LPCWSTR optional -> "char*"
# dwGopherType : DWORD -> "dword"
# lpszLocator : LPWSTR optional, out -> "char*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。