Win32 API 日本語リファレンス
ホームStorage.FileSystem › FindClose

FindClose

関数
ファイル検索ハンドルを閉じて検索を終了する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL FindClose(
    HANDLE hFindFile
);

パラメーター

名前方向
hFindFileHANDLEinout

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL FindClose(
    HANDLE hFindFile
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool FindClose(
    IntPtr hFindFile   // HANDLE in/out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindClose(
    hFindFile As IntPtr   ' HANDLE in/out
) As Boolean
End Function
' hFindFile : HANDLE in/out
Declare PtrSafe Function FindClose Lib "kernel32" ( _
    ByVal hFindFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FindClose = ctypes.windll.kernel32.FindClose
FindClose.restype = wintypes.BOOL
FindClose.argtypes = [
    wintypes.HANDLE,  # hFindFile : HANDLE in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
FindClose = Fiddle::Function.new(
  lib['FindClose'],
  [
    Fiddle::TYPE_VOIDP,  # hFindFile : HANDLE in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn FindClose(
        hFindFile: *mut core::ffi::c_void  // HANDLE in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool FindClose(IntPtr hFindFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindClose' -Namespace Win32 -PassThru
# $api::FindClose(hFindFile)
#uselib "KERNEL32.dll"
#func global FindClose "FindClose" sptr
; FindClose hFindFile   ; 戻り値は stat
; hFindFile : HANDLE in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global FindClose "FindClose" sptr
; res = FindClose(hFindFile)
; hFindFile : HANDLE in/out -> "sptr"
; BOOL FindClose(HANDLE hFindFile)
#uselib "KERNEL32.dll"
#cfunc global FindClose "FindClose" intptr
; res = FindClose(hFindFile)
; hFindFile : HANDLE in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindClose = kernel32.NewProc("FindClose")
)

// hFindFile (HANDLE in/out)
r1, _, err := procFindClose.Call(
	uintptr(hFindFile),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FindClose(
  hFindFile: THandle   // HANDLE in/out
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'FindClose';
result := DllCall("KERNEL32\FindClose"
    , "Ptr", hFindFile   ; HANDLE in/out
    , "Int")   ; return: BOOL
●FindClose(hFindFile) = DLL("KERNEL32.dll", "bool FindClose(void*)")
# 呼び出し: FindClose(hFindFile)
# hFindFile : HANDLE in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。