ホーム › Storage.FileHistory › FhServiceOpenPipe
FhServiceOpenPipe
関数ファイル履歴サービスへの制御パイプを開く。
シグネチャ
// fhsvcctl.dll
#include <windows.h>
HRESULT FhServiceOpenPipe(
BOOL StartServiceIfStopped,
FH_SERVICE_PIPE_HANDLE* Pipe
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| StartServiceIfStopped | BOOL | in | ファイル履歴サービスが停止中の場合に起動するかどうかのフラグ。TRUEで自動起動する。 |
| Pipe | FH_SERVICE_PIPE_HANDLE* | out | 開いたサービス通信パイプのハンドルを受け取るFH_SERVICE_PIPE_HANDLEへのポインタ。出力用。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// fhsvcctl.dll
#include <windows.h>
HRESULT FhServiceOpenPipe(
BOOL StartServiceIfStopped,
FH_SERVICE_PIPE_HANDLE* Pipe
);[DllImport("fhsvcctl.dll", ExactSpelling = true)]
static extern int FhServiceOpenPipe(
bool StartServiceIfStopped, // BOOL
IntPtr Pipe // FH_SERVICE_PIPE_HANDLE* out
);<DllImport("fhsvcctl.dll", ExactSpelling:=True)>
Public Shared Function FhServiceOpenPipe(
StartServiceIfStopped As Boolean, ' BOOL
Pipe As IntPtr ' FH_SERVICE_PIPE_HANDLE* out
) As Integer
End Function' StartServiceIfStopped : BOOL
' Pipe : FH_SERVICE_PIPE_HANDLE* out
Declare PtrSafe Function FhServiceOpenPipe Lib "fhsvcctl" ( _
ByVal StartServiceIfStopped As Long, _
ByVal Pipe As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FhServiceOpenPipe = ctypes.windll.fhsvcctl.FhServiceOpenPipe
FhServiceOpenPipe.restype = ctypes.c_int
FhServiceOpenPipe.argtypes = [
wintypes.BOOL, # StartServiceIfStopped : BOOL
ctypes.c_void_p, # Pipe : FH_SERVICE_PIPE_HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('fhsvcctl.dll')
FhServiceOpenPipe = Fiddle::Function.new(
lib['FhServiceOpenPipe'],
[
Fiddle::TYPE_INT, # StartServiceIfStopped : BOOL
Fiddle::TYPE_VOIDP, # Pipe : FH_SERVICE_PIPE_HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "fhsvcctl")]
extern "system" {
fn FhServiceOpenPipe(
StartServiceIfStopped: i32, // BOOL
Pipe: *mut *mut core::ffi::c_void // FH_SERVICE_PIPE_HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("fhsvcctl.dll")]
public static extern int FhServiceOpenPipe(bool StartServiceIfStopped, IntPtr Pipe);
"@
$api = Add-Type -MemberDefinition $sig -Name 'fhsvcctl_FhServiceOpenPipe' -Namespace Win32 -PassThru
# $api::FhServiceOpenPipe(StartServiceIfStopped, Pipe)#uselib "fhsvcctl.dll"
#func global FhServiceOpenPipe "FhServiceOpenPipe" sptr, sptr
; FhServiceOpenPipe StartServiceIfStopped, Pipe ; 戻り値は stat
; StartServiceIfStopped : BOOL -> "sptr"
; Pipe : FH_SERVICE_PIPE_HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "fhsvcctl.dll"
#cfunc global FhServiceOpenPipe "FhServiceOpenPipe" int, sptr
; res = FhServiceOpenPipe(StartServiceIfStopped, Pipe)
; StartServiceIfStopped : BOOL -> "int"
; Pipe : FH_SERVICE_PIPE_HANDLE* out -> "sptr"; HRESULT FhServiceOpenPipe(BOOL StartServiceIfStopped, FH_SERVICE_PIPE_HANDLE* Pipe)
#uselib "fhsvcctl.dll"
#cfunc global FhServiceOpenPipe "FhServiceOpenPipe" int, intptr
; res = FhServiceOpenPipe(StartServiceIfStopped, Pipe)
; StartServiceIfStopped : BOOL -> "int"
; Pipe : FH_SERVICE_PIPE_HANDLE* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
fhsvcctl = windows.NewLazySystemDLL("fhsvcctl.dll")
procFhServiceOpenPipe = fhsvcctl.NewProc("FhServiceOpenPipe")
)
// StartServiceIfStopped (BOOL), Pipe (FH_SERVICE_PIPE_HANDLE* out)
r1, _, err := procFhServiceOpenPipe.Call(
uintptr(StartServiceIfStopped),
uintptr(Pipe),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction FhServiceOpenPipe(
StartServiceIfStopped: BOOL; // BOOL
Pipe: Pointer // FH_SERVICE_PIPE_HANDLE* out
): Integer; stdcall;
external 'fhsvcctl.dll' name 'FhServiceOpenPipe';result := DllCall("fhsvcctl\FhServiceOpenPipe"
, "Int", StartServiceIfStopped ; BOOL
, "Ptr", Pipe ; FH_SERVICE_PIPE_HANDLE* out
, "Int") ; return: HRESULT●FhServiceOpenPipe(StartServiceIfStopped, Pipe) = DLL("fhsvcctl.dll", "int FhServiceOpenPipe(bool, void*)")
# 呼び出し: FhServiceOpenPipe(StartServiceIfStopped, Pipe)
# StartServiceIfStopped : BOOL -> "bool"
# Pipe : FH_SERVICE_PIPE_HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "fhsvcctl" fn FhServiceOpenPipe(
StartServiceIfStopped: i32, // BOOL
Pipe: ?*anyopaque // FH_SERVICE_PIPE_HANDLE* out
) callconv(std.os.windows.WINAPI) i32;proc FhServiceOpenPipe(
StartServiceIfStopped: int32, # BOOL
Pipe: pointer # FH_SERVICE_PIPE_HANDLE* out
): int32 {.importc: "FhServiceOpenPipe", stdcall, dynlib: "fhsvcctl.dll".}pragma(lib, "fhsvcctl");
extern(Windows)
int FhServiceOpenPipe(
int StartServiceIfStopped, // BOOL
void* Pipe // FH_SERVICE_PIPE_HANDLE* out
);ccall((:FhServiceOpenPipe, "fhsvcctl.dll"), stdcall, Int32,
(Int32, Ptr{Cvoid}),
StartServiceIfStopped, Pipe)
# StartServiceIfStopped : BOOL -> Int32
# Pipe : FH_SERVICE_PIPE_HANDLE* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t FhServiceOpenPipe(
int32_t StartServiceIfStopped,
void* Pipe);
]]
local fhsvcctl = ffi.load("fhsvcctl")
-- fhsvcctl.FhServiceOpenPipe(StartServiceIfStopped, Pipe)
-- StartServiceIfStopped : BOOL
-- Pipe : FH_SERVICE_PIPE_HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('fhsvcctl.dll');
const FhServiceOpenPipe = lib.func('__stdcall', 'FhServiceOpenPipe', 'int32_t', ['int32_t', 'void *']);
// FhServiceOpenPipe(StartServiceIfStopped, Pipe)
// StartServiceIfStopped : BOOL -> 'int32_t'
// Pipe : FH_SERVICE_PIPE_HANDLE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("fhsvcctl.dll", {
FhServiceOpenPipe: { parameters: ["i32", "pointer"], result: "i32" },
});
// lib.symbols.FhServiceOpenPipe(StartServiceIfStopped, Pipe)
// StartServiceIfStopped : BOOL -> "i32"
// Pipe : FH_SERVICE_PIPE_HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t FhServiceOpenPipe(
int32_t StartServiceIfStopped,
void* Pipe);
C, "fhsvcctl.dll");
// $ffi->FhServiceOpenPipe(StartServiceIfStopped, Pipe);
// StartServiceIfStopped : BOOL
// Pipe : FH_SERVICE_PIPE_HANDLE* out
// 構造体/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 Fhsvcctl extends StdCallLibrary {
Fhsvcctl INSTANCE = Native.load("fhsvcctl", Fhsvcctl.class);
int FhServiceOpenPipe(
boolean StartServiceIfStopped, // BOOL
Pointer Pipe // FH_SERVICE_PIPE_HANDLE* out
);
}@[Link("fhsvcctl")]
lib Libfhsvcctl
fun FhServiceOpenPipe = FhServiceOpenPipe(
StartServiceIfStopped : Int32, # BOOL
Pipe : Void* # FH_SERVICE_PIPE_HANDLE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FhServiceOpenPipeNative = Int32 Function(Int32, Pointer<Void>);
typedef FhServiceOpenPipeDart = int Function(int, Pointer<Void>);
final FhServiceOpenPipe = DynamicLibrary.open('fhsvcctl.dll')
.lookupFunction<FhServiceOpenPipeNative, FhServiceOpenPipeDart>('FhServiceOpenPipe');
// StartServiceIfStopped : BOOL -> Int32
// Pipe : FH_SERVICE_PIPE_HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FhServiceOpenPipe(
StartServiceIfStopped: BOOL; // BOOL
Pipe: Pointer // FH_SERVICE_PIPE_HANDLE* out
): Integer; stdcall;
external 'fhsvcctl.dll' name 'FhServiceOpenPipe';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FhServiceOpenPipe"
c_FhServiceOpenPipe :: CInt -> Ptr () -> IO Int32
-- StartServiceIfStopped : BOOL -> CInt
-- Pipe : FH_SERVICE_PIPE_HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let fhserviceopenpipe =
foreign "FhServiceOpenPipe"
(int32_t @-> (ptr void) @-> returning int32_t)
(* StartServiceIfStopped : BOOL -> int32_t *)
(* Pipe : FH_SERVICE_PIPE_HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library fhsvcctl (t "fhsvcctl.dll"))
(cffi:use-foreign-library fhsvcctl)
(cffi:defcfun ("FhServiceOpenPipe" fh-service-open-pipe :convention :stdcall) :int32
(start-service-if-stopped :int32) ; BOOL
(pipe :pointer)) ; FH_SERVICE_PIPE_HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FhServiceOpenPipe = Win32::API::More->new('fhsvcctl',
'int FhServiceOpenPipe(BOOL StartServiceIfStopped, HANDLE Pipe)');
# my $ret = $FhServiceOpenPipe->Call($StartServiceIfStopped, $Pipe);
# StartServiceIfStopped : BOOL -> BOOL
# Pipe : FH_SERVICE_PIPE_HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。