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

WHvCancelPartitionMigration

関数
パーティションのマイグレーションを取り消す。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvCancelPartitionMigration(
    WHV_PARTITION_HANDLE Partition
);

パラメーター

名前方向説明
PartitionWHV_PARTITION_HANDLEin進行中の移行をキャンセルする対象パーティションのハンドルを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvCancelPartitionMigration(
    WHV_PARTITION_HANDLE Partition
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvCancelPartitionMigration(
    IntPtr Partition   // WHV_PARTITION_HANDLE
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvCancelPartitionMigration(
    Partition As IntPtr   ' WHV_PARTITION_HANDLE
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
Declare PtrSafe Function WHvCancelPartitionMigration Lib "winhvplatform" ( _
    ByVal Partition As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvCancelPartitionMigration = ctypes.windll.winhvplatform.WHvCancelPartitionMigration
WHvCancelPartitionMigration.restype = ctypes.c_int
WHvCancelPartitionMigration.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvCancelPartitionMigration = Fiddle::Function.new(
  lib['WHvCancelPartitionMigration'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvCancelPartitionMigration(
        Partition: isize  // WHV_PARTITION_HANDLE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvCancelPartitionMigration(IntPtr Partition);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvCancelPartitionMigration' -Namespace Win32 -PassThru
# $api::WHvCancelPartitionMigration(Partition)
#uselib "WinHvPlatform.dll"
#func global WHvCancelPartitionMigration "WHvCancelPartitionMigration" sptr
; WHvCancelPartitionMigration Partition   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WinHvPlatform.dll"
#cfunc global WHvCancelPartitionMigration "WHvCancelPartitionMigration" sptr
; res = WHvCancelPartitionMigration(Partition)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; HRESULT WHvCancelPartitionMigration(WHV_PARTITION_HANDLE Partition)
#uselib "WinHvPlatform.dll"
#cfunc global WHvCancelPartitionMigration "WHvCancelPartitionMigration" intptr
; res = WHvCancelPartitionMigration(Partition)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvCancelPartitionMigration = winhvplatform.NewProc("WHvCancelPartitionMigration")
)

// Partition (WHV_PARTITION_HANDLE)
r1, _, err := procWHvCancelPartitionMigration.Call(
	uintptr(Partition),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvCancelPartitionMigration(
  Partition: NativeInt   // WHV_PARTITION_HANDLE
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvCancelPartitionMigration';
result := DllCall("WinHvPlatform\WHvCancelPartitionMigration"
    , "Ptr", Partition   ; WHV_PARTITION_HANDLE
    , "Int")   ; return: HRESULT
●WHvCancelPartitionMigration(Partition) = DLL("WinHvPlatform.dll", "int WHvCancelPartitionMigration(int)")
# 呼び出し: WHvCancelPartitionMigration(Partition)
# Partition : WHV_PARTITION_HANDLE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winhvplatform" fn WHvCancelPartitionMigration(
    Partition: isize // WHV_PARTITION_HANDLE
) callconv(std.os.windows.WINAPI) i32;
proc WHvCancelPartitionMigration(
    Partition: int  # WHV_PARTITION_HANDLE
): int32 {.importc: "WHvCancelPartitionMigration", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvCancelPartitionMigration(
    ptrdiff_t Partition   // WHV_PARTITION_HANDLE
);
ccall((:WHvCancelPartitionMigration, "WinHvPlatform.dll"), stdcall, Int32,
      (Int,),
      Partition)
# Partition : WHV_PARTITION_HANDLE -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvCancelPartitionMigration(
    intptr_t Partition);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvCancelPartitionMigration(Partition)
-- Partition : WHV_PARTITION_HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvCancelPartitionMigration = lib.func('__stdcall', 'WHvCancelPartitionMigration', 'int32_t', ['intptr_t']);
// WHvCancelPartitionMigration(Partition)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvCancelPartitionMigration: { parameters: ["isize"], result: "i32" },
});
// lib.symbols.WHvCancelPartitionMigration(Partition)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvCancelPartitionMigration(
    intptr_t Partition);
C, "WinHvPlatform.dll");
// $ffi->WHvCancelPartitionMigration(Partition);
// Partition : WHV_PARTITION_HANDLE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Winhvplatform extends StdCallLibrary {
    Winhvplatform INSTANCE = Native.load("winhvplatform", Winhvplatform.class);
    int WHvCancelPartitionMigration(
        long Partition   // WHV_PARTITION_HANDLE
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvCancelPartitionMigration = WHvCancelPartitionMigration(
    Partition : LibC::SSizeT   # WHV_PARTITION_HANDLE
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WHvCancelPartitionMigrationNative = Int32 Function(IntPtr);
typedef WHvCancelPartitionMigrationDart = int Function(int);
final WHvCancelPartitionMigration = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvCancelPartitionMigrationNative, WHvCancelPartitionMigrationDart>('WHvCancelPartitionMigration');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvCancelPartitionMigration(
  Partition: NativeInt   // WHV_PARTITION_HANDLE
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvCancelPartitionMigration';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvCancelPartitionMigration"
  c_WHvCancelPartitionMigration :: CIntPtr -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvcancelpartitionmigration =
  foreign "WHvCancelPartitionMigration"
    (intptr_t @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)

(cffi:defcfun ("WHvCancelPartitionMigration" whv-cancel-partition-migration :convention :stdcall) :int32
  (partition :int64))   ; WHV_PARTITION_HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvCancelPartitionMigration = Win32::API::More->new('WinHvPlatform',
    'int WHvCancelPartitionMigration(LPARAM Partition)');
# my $ret = $WHvCancelPartitionMigration->Call($Partition);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。