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

OfflineFilesEnable

関数
オフラインファイル機能の有効・無効を切り替える。
DLLCSCAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD OfflineFilesEnable(
    BOOL bEnable,
    BOOL* pbRebootRequired
);

パラメーター

名前方向
bEnableBOOLin
pbRebootRequiredBOOL*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD OfflineFilesEnable(
    BOOL bEnable,
    BOOL* pbRebootRequired
);
[DllImport("CSCAPI.dll", ExactSpelling = true)]
static extern uint OfflineFilesEnable(
    bool bEnable,   // BOOL
    out int pbRebootRequired   // BOOL* out
);
<DllImport("CSCAPI.dll", ExactSpelling:=True)>
Public Shared Function OfflineFilesEnable(
    bEnable As Boolean,   ' BOOL
    <Out> ByRef pbRebootRequired As Integer   ' BOOL* out
) As UInteger
End Function
' bEnable : BOOL
' pbRebootRequired : BOOL* out
Declare PtrSafe Function OfflineFilesEnable Lib "cscapi" ( _
    ByVal bEnable As Long, _
    ByRef pbRebootRequired As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OfflineFilesEnable = ctypes.windll.cscapi.OfflineFilesEnable
OfflineFilesEnable.restype = wintypes.DWORD
OfflineFilesEnable.argtypes = [
    wintypes.BOOL,  # bEnable : BOOL
    ctypes.c_void_p,  # pbRebootRequired : BOOL* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CSCAPI.dll')
OfflineFilesEnable = Fiddle::Function.new(
  lib['OfflineFilesEnable'],
  [
    Fiddle::TYPE_INT,  # bEnable : BOOL
    Fiddle::TYPE_VOIDP,  # pbRebootRequired : BOOL* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "cscapi")]
extern "system" {
    fn OfflineFilesEnable(
        bEnable: i32,  // BOOL
        pbRebootRequired: *mut i32  // BOOL* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CSCAPI.dll")]
public static extern uint OfflineFilesEnable(bool bEnable, out int pbRebootRequired);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CSCAPI_OfflineFilesEnable' -Namespace Win32 -PassThru
# $api::OfflineFilesEnable(bEnable, pbRebootRequired)
#uselib "CSCAPI.dll"
#func global OfflineFilesEnable "OfflineFilesEnable" sptr, sptr
; OfflineFilesEnable bEnable, pbRebootRequired   ; 戻り値は stat
; bEnable : BOOL -> "sptr"
; pbRebootRequired : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CSCAPI.dll"
#cfunc global OfflineFilesEnable "OfflineFilesEnable" int, int
; res = OfflineFilesEnable(bEnable, pbRebootRequired)
; bEnable : BOOL -> "int"
; pbRebootRequired : BOOL* out -> "int"
; DWORD OfflineFilesEnable(BOOL bEnable, BOOL* pbRebootRequired)
#uselib "CSCAPI.dll"
#cfunc global OfflineFilesEnable "OfflineFilesEnable" int, int
; res = OfflineFilesEnable(bEnable, pbRebootRequired)
; bEnable : BOOL -> "int"
; pbRebootRequired : BOOL* out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cscapi = windows.NewLazySystemDLL("CSCAPI.dll")
	procOfflineFilesEnable = cscapi.NewProc("OfflineFilesEnable")
)

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