Win32 API 日本語リファレンス
ホームSystem.Threading › FlsSetValue

FlsSetValue

関数
ファイバーローカルストレージスロットに値を設定する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL FlsSetValue(
    DWORD dwFlsIndex,
    void* lpFlsData   // optional
);

パラメーター

名前方向
dwFlsIndexDWORDin
lpFlsDatavoid*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

FlsSetValue = ctypes.windll.kernel32.FlsSetValue
FlsSetValue.restype = wintypes.BOOL
FlsSetValue.argtypes = [
    wintypes.DWORD,  # dwFlsIndex : DWORD
    ctypes.POINTER(None),  # lpFlsData : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
FlsSetValue = Fiddle::Function.new(
  lib['FlsSetValue'],
  [
    -Fiddle::TYPE_INT,  # dwFlsIndex : DWORD
    Fiddle::TYPE_VOIDP,  # lpFlsData : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn FlsSetValue(
        dwFlsIndex: u32,  // DWORD
        lpFlsData: *mut ()  // void* optional
    ) -> 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 FlsSetValue(uint dwFlsIndex, IntPtr lpFlsData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FlsSetValue' -Namespace Win32 -PassThru
# $api::FlsSetValue(dwFlsIndex, lpFlsData)
#uselib "KERNEL32.dll"
#func global FlsSetValue "FlsSetValue" sptr, sptr
; FlsSetValue dwFlsIndex, lpFlsData   ; 戻り値は stat
; dwFlsIndex : DWORD -> "sptr"
; lpFlsData : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global FlsSetValue "FlsSetValue" int, sptr
; res = FlsSetValue(dwFlsIndex, lpFlsData)
; dwFlsIndex : DWORD -> "int"
; lpFlsData : void* optional -> "sptr"
; BOOL FlsSetValue(DWORD dwFlsIndex, void* lpFlsData)
#uselib "KERNEL32.dll"
#cfunc global FlsSetValue "FlsSetValue" int, intptr
; res = FlsSetValue(dwFlsIndex, lpFlsData)
; dwFlsIndex : DWORD -> "int"
; lpFlsData : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFlsSetValue = kernel32.NewProc("FlsSetValue")
)

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