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

GopherOpenFileW

関数
Gopherサーバー上の項目を読み取り用に開く(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

void* GopherOpenFileW(
    void* hConnect,
    LPCWSTR lpszLocator,
    LPCWSTR lpszView,   // optional
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);

パラメーター

名前方向
hConnectvoid*in
lpszLocatorLPCWSTRin
lpszViewLPCWSTRinoptional
dwFlagsDWORDin
dwContextUINT_PTRinoptional

戻り値の型: void*

各言語での呼び出し定義

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

void* GopherOpenFileW(
    void* hConnect,
    LPCWSTR lpszLocator,
    LPCWSTR lpszView,   // optional
    DWORD dwFlags,
    UINT_PTR dwContext   // optional
);
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr GopherOpenFileW(
    IntPtr hConnect,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string lpszLocator,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszView,   // LPCWSTR optional
    uint dwFlags,   // DWORD
    UIntPtr dwContext   // UINT_PTR optional
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GopherOpenFileW(
    hConnect As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> lpszLocator As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszView As String,   ' LPCWSTR optional
    dwFlags As UInteger,   ' DWORD
    dwContext As UIntPtr   ' UINT_PTR optional
) As IntPtr
End Function
' hConnect : void*
' lpszLocator : LPCWSTR
' lpszView : LPCWSTR optional
' dwFlags : DWORD
' dwContext : UINT_PTR optional
Declare PtrSafe Function GopherOpenFileW Lib "wininet" ( _
    ByVal hConnect As LongPtr, _
    ByVal lpszLocator As LongPtr, _
    ByVal lpszView As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal dwContext As LongPtr) As LongPtr
' 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

GopherOpenFileW = ctypes.windll.wininet.GopherOpenFileW
GopherOpenFileW.restype = ctypes.c_void_p
GopherOpenFileW.argtypes = [
    ctypes.POINTER(None),  # hConnect : void*
    wintypes.LPCWSTR,  # lpszLocator : LPCWSTR
    wintypes.LPCWSTR,  # lpszView : LPCWSTR optional
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.c_size_t,  # dwContext : UINT_PTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
GopherOpenFileW = Fiddle::Function.new(
  lib['GopherOpenFileW'],
  [
    Fiddle::TYPE_VOIDP,  # hConnect : void*
    Fiddle::TYPE_VOIDP,  # lpszLocator : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszView : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwContext : UINT_PTR optional
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn GopherOpenFileW(
        hConnect: *mut (),  // void*
        lpszLocator: *const u16,  // LPCWSTR
        lpszView: *const u16,  // LPCWSTR optional
        dwFlags: u32,  // DWORD
        dwContext: usize  // UINT_PTR optional
    ) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr GopherOpenFileW(IntPtr hConnect, [MarshalAs(UnmanagedType.LPWStr)] string lpszLocator, [MarshalAs(UnmanagedType.LPWStr)] string lpszView, uint dwFlags, UIntPtr dwContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_GopherOpenFileW' -Namespace Win32 -PassThru
# $api::GopherOpenFileW(hConnect, lpszLocator, lpszView, dwFlags, dwContext)
#uselib "WININET.dll"
#func global GopherOpenFileW "GopherOpenFileW" wptr, wptr, wptr, wptr, wptr
; GopherOpenFileW hConnect, lpszLocator, lpszView, dwFlags, dwContext   ; 戻り値は stat
; hConnect : void* -> "wptr"
; lpszLocator : LPCWSTR -> "wptr"
; lpszView : LPCWSTR optional -> "wptr"
; dwFlags : DWORD -> "wptr"
; dwContext : UINT_PTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global GopherOpenFileW "GopherOpenFileW" sptr, wstr, wstr, int, sptr
; res = GopherOpenFileW(hConnect, lpszLocator, lpszView, dwFlags, dwContext)
; hConnect : void* -> "sptr"
; lpszLocator : LPCWSTR -> "wstr"
; lpszView : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "sptr"
; void* GopherOpenFileW(void* hConnect, LPCWSTR lpszLocator, LPCWSTR lpszView, DWORD dwFlags, UINT_PTR dwContext)
#uselib "WININET.dll"
#cfunc global GopherOpenFileW "GopherOpenFileW" intptr, wstr, wstr, int, intptr
; res = GopherOpenFileW(hConnect, lpszLocator, lpszView, dwFlags, dwContext)
; hConnect : void* -> "intptr"
; lpszLocator : LPCWSTR -> "wstr"
; lpszView : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; dwContext : UINT_PTR optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procGopherOpenFileW = wininet.NewProc("GopherOpenFileW")
)

// hConnect (void*), lpszLocator (LPCWSTR), lpszView (LPCWSTR optional), dwFlags (DWORD), dwContext (UINT_PTR optional)
r1, _, err := procGopherOpenFileW.Call(
	uintptr(hConnect),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszLocator))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszView))),
	uintptr(dwFlags),
	uintptr(dwContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void*
function GopherOpenFileW(
  hConnect: Pointer;   // void*
  lpszLocator: PWideChar;   // LPCWSTR
  lpszView: PWideChar;   // LPCWSTR optional
  dwFlags: DWORD;   // DWORD
  dwContext: NativeUInt   // UINT_PTR optional
): Pointer; stdcall;
  external 'WININET.dll' name 'GopherOpenFileW';
result := DllCall("WININET\GopherOpenFileW"
    , "Ptr", hConnect   ; void*
    , "WStr", lpszLocator   ; LPCWSTR
    , "WStr", lpszView   ; LPCWSTR optional
    , "UInt", dwFlags   ; DWORD
    , "UPtr", dwContext   ; UINT_PTR optional
    , "Ptr")   ; return: void*
●GopherOpenFileW(hConnect, lpszLocator, lpszView, dwFlags, dwContext) = DLL("WININET.dll", "void* GopherOpenFileW(void*, char*, char*, dword, int)")
# 呼び出し: GopherOpenFileW(hConnect, lpszLocator, lpszView, dwFlags, dwContext)
# hConnect : void* -> "void*"
# lpszLocator : LPCWSTR -> "char*"
# lpszView : LPCWSTR optional -> "char*"
# dwFlags : DWORD -> "dword"
# dwContext : UINT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。