ホーム › Networking.WinInet › FtpSetCurrentDirectoryW
FtpSetCurrentDirectoryW
関数FTPセッションのカレントディレクトリを変更する(Unicode版)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL FtpSetCurrentDirectoryW(
void* hConnect,
LPCWSTR lpszDirectory
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConnect | void* | in |
| lpszDirectory | LPCWSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL FtpSetCurrentDirectoryW(
void* hConnect,
LPCWSTR lpszDirectory
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool FtpSetCurrentDirectoryW(
IntPtr hConnect, // void*
[MarshalAs(UnmanagedType.LPWStr)] string lpszDirectory // LPCWSTR
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FtpSetCurrentDirectoryW(
hConnect As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> lpszDirectory As String ' LPCWSTR
) As Boolean
End Function' hConnect : void*
' lpszDirectory : LPCWSTR
Declare PtrSafe Function FtpSetCurrentDirectoryW Lib "wininet" ( _
ByVal hConnect As LongPtr, _
ByVal lpszDirectory As LongPtr) 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
FtpSetCurrentDirectoryW = ctypes.windll.wininet.FtpSetCurrentDirectoryW
FtpSetCurrentDirectoryW.restype = wintypes.BOOL
FtpSetCurrentDirectoryW.argtypes = [
ctypes.POINTER(None), # hConnect : void*
wintypes.LPCWSTR, # lpszDirectory : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
FtpSetCurrentDirectoryW = Fiddle::Function.new(
lib['FtpSetCurrentDirectoryW'],
[
Fiddle::TYPE_VOIDP, # hConnect : void*
Fiddle::TYPE_VOIDP, # lpszDirectory : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn FtpSetCurrentDirectoryW(
hConnect: *mut (), // void*
lpszDirectory: *const u16 // LPCWSTR
) -> 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 FtpSetCurrentDirectoryW(IntPtr hConnect, [MarshalAs(UnmanagedType.LPWStr)] string lpszDirectory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_FtpSetCurrentDirectoryW' -Namespace Win32 -PassThru
# $api::FtpSetCurrentDirectoryW(hConnect, lpszDirectory)#uselib "WININET.dll"
#func global FtpSetCurrentDirectoryW "FtpSetCurrentDirectoryW" wptr, wptr
; FtpSetCurrentDirectoryW hConnect, lpszDirectory ; 戻り値は stat
; hConnect : void* -> "wptr"
; lpszDirectory : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global FtpSetCurrentDirectoryW "FtpSetCurrentDirectoryW" sptr, wstr
; res = FtpSetCurrentDirectoryW(hConnect, lpszDirectory)
; hConnect : void* -> "sptr"
; lpszDirectory : LPCWSTR -> "wstr"; BOOL FtpSetCurrentDirectoryW(void* hConnect, LPCWSTR lpszDirectory)
#uselib "WININET.dll"
#cfunc global FtpSetCurrentDirectoryW "FtpSetCurrentDirectoryW" intptr, wstr
; res = FtpSetCurrentDirectoryW(hConnect, lpszDirectory)
; hConnect : void* -> "intptr"
; lpszDirectory : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procFtpSetCurrentDirectoryW = wininet.NewProc("FtpSetCurrentDirectoryW")
)
// hConnect (void*), lpszDirectory (LPCWSTR)
r1, _, err := procFtpSetCurrentDirectoryW.Call(
uintptr(hConnect),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDirectory))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction FtpSetCurrentDirectoryW(
hConnect: Pointer; // void*
lpszDirectory: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'WININET.dll' name 'FtpSetCurrentDirectoryW';result := DllCall("WININET\FtpSetCurrentDirectoryW"
, "Ptr", hConnect ; void*
, "WStr", lpszDirectory ; LPCWSTR
, "Int") ; return: BOOL●FtpSetCurrentDirectoryW(hConnect, lpszDirectory) = DLL("WININET.dll", "bool FtpSetCurrentDirectoryW(void*, char*)")
# 呼び出し: FtpSetCurrentDirectoryW(hConnect, lpszDirectory)
# hConnect : void* -> "void*"
# lpszDirectory : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。