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

BackupPerfRegistryToFileW

関数
パフォーマンスレジストリ情報をファイルにバックアップする。
DLLloadperf.dll呼出規約winapi

シグネチャ

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

DWORD BackupPerfRegistryToFileW(
    LPCWSTR szFileName,
    LPCWSTR szCommentString   // optional
);

パラメーター

名前方向説明
szFileNameLPCWSTRinパフォーマンスレジストリ情報のバックアップ先ファイル名。
szCommentStringLPCWSTRinoptionalバックアップファイルに付与するコメント文字列。NULL可。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD BackupPerfRegistryToFileW(
    LPCWSTR szFileName,
    LPCWSTR szCommentString   // optional
);
[DllImport("loadperf.dll", ExactSpelling = true)]
static extern uint BackupPerfRegistryToFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string szFileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szCommentString   // LPCWSTR optional
);
<DllImport("loadperf.dll", ExactSpelling:=True)>
Public Shared Function BackupPerfRegistryToFileW(
    <MarshalAs(UnmanagedType.LPWStr)> szFileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szCommentString As String   ' LPCWSTR optional
) As UInteger
End Function
' szFileName : LPCWSTR
' szCommentString : LPCWSTR optional
Declare PtrSafe Function BackupPerfRegistryToFileW Lib "loadperf" ( _
    ByVal szFileName As LongPtr, _
    ByVal szCommentString As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BackupPerfRegistryToFileW = ctypes.windll.loadperf.BackupPerfRegistryToFileW
BackupPerfRegistryToFileW.restype = wintypes.DWORD
BackupPerfRegistryToFileW.argtypes = [
    wintypes.LPCWSTR,  # szFileName : LPCWSTR
    wintypes.LPCWSTR,  # szCommentString : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('loadperf.dll')
BackupPerfRegistryToFileW = Fiddle::Function.new(
  lib['BackupPerfRegistryToFileW'],
  [
    Fiddle::TYPE_VOIDP,  # szFileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szCommentString : LPCWSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "loadperf")]
extern "system" {
    fn BackupPerfRegistryToFileW(
        szFileName: *const u16,  // LPCWSTR
        szCommentString: *const u16  // LPCWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("loadperf.dll")]
public static extern uint BackupPerfRegistryToFileW([MarshalAs(UnmanagedType.LPWStr)] string szFileName, [MarshalAs(UnmanagedType.LPWStr)] string szCommentString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'loadperf_BackupPerfRegistryToFileW' -Namespace Win32 -PassThru
# $api::BackupPerfRegistryToFileW(szFileName, szCommentString)
#uselib "loadperf.dll"
#func global BackupPerfRegistryToFileW "BackupPerfRegistryToFileW" sptr, sptr
; BackupPerfRegistryToFileW szFileName, szCommentString   ; 戻り値は stat
; szFileName : LPCWSTR -> "sptr"
; szCommentString : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "loadperf.dll"
#cfunc global BackupPerfRegistryToFileW "BackupPerfRegistryToFileW" wstr, wstr
; res = BackupPerfRegistryToFileW(szFileName, szCommentString)
; szFileName : LPCWSTR -> "wstr"
; szCommentString : LPCWSTR optional -> "wstr"
; DWORD BackupPerfRegistryToFileW(LPCWSTR szFileName, LPCWSTR szCommentString)
#uselib "loadperf.dll"
#cfunc global BackupPerfRegistryToFileW "BackupPerfRegistryToFileW" wstr, wstr
; res = BackupPerfRegistryToFileW(szFileName, szCommentString)
; szFileName : LPCWSTR -> "wstr"
; szCommentString : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	loadperf = windows.NewLazySystemDLL("loadperf.dll")
	procBackupPerfRegistryToFileW = loadperf.NewProc("BackupPerfRegistryToFileW")
)

// szFileName (LPCWSTR), szCommentString (LPCWSTR optional)
r1, _, err := procBackupPerfRegistryToFileW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szCommentString))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function BackupPerfRegistryToFileW(
  szFileName: PWideChar;   // LPCWSTR
  szCommentString: PWideChar   // LPCWSTR optional
): DWORD; stdcall;
  external 'loadperf.dll' name 'BackupPerfRegistryToFileW';
result := DllCall("loadperf\BackupPerfRegistryToFileW"
    , "WStr", szFileName   ; LPCWSTR
    , "WStr", szCommentString   ; LPCWSTR optional
    , "UInt")   ; return: DWORD
●BackupPerfRegistryToFileW(szFileName, szCommentString) = DLL("loadperf.dll", "dword BackupPerfRegistryToFileW(char*, char*)")
# 呼び出し: BackupPerfRegistryToFileW(szFileName, szCommentString)
# szFileName : LPCWSTR -> "char*"
# szCommentString : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "loadperf" fn BackupPerfRegistryToFileW(
    szFileName: [*c]const u16, // LPCWSTR
    szCommentString: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;
proc BackupPerfRegistryToFileW(
    szFileName: WideCString,  # LPCWSTR
    szCommentString: WideCString  # LPCWSTR optional
): uint32 {.importc: "BackupPerfRegistryToFileW", stdcall, dynlib: "loadperf.dll".}
pragma(lib, "loadperf");
extern(Windows)
uint BackupPerfRegistryToFileW(
    const(wchar)* szFileName,   // LPCWSTR
    const(wchar)* szCommentString   // LPCWSTR optional
);
ccall((:BackupPerfRegistryToFileW, "loadperf.dll"), stdcall, UInt32,
      (Cwstring, Cwstring),
      szFileName, szCommentString)
# szFileName : LPCWSTR -> Cwstring
# szCommentString : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t BackupPerfRegistryToFileW(
    const uint16_t* szFileName,
    const uint16_t* szCommentString);
]]
local loadperf = ffi.load("loadperf")
-- loadperf.BackupPerfRegistryToFileW(szFileName, szCommentString)
-- szFileName : LPCWSTR
-- szCommentString : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('loadperf.dll');
const BackupPerfRegistryToFileW = lib.func('__stdcall', 'BackupPerfRegistryToFileW', 'uint32_t', ['str16', 'str16']);
// BackupPerfRegistryToFileW(szFileName, szCommentString)
// szFileName : LPCWSTR -> 'str16'
// szCommentString : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("loadperf.dll", {
  BackupPerfRegistryToFileW: { parameters: ["buffer", "buffer"], result: "u32" },
});
// lib.symbols.BackupPerfRegistryToFileW(szFileName, szCommentString)
// szFileName : LPCWSTR -> "buffer"
// szCommentString : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t BackupPerfRegistryToFileW(
    const uint16_t* szFileName,
    const uint16_t* szCommentString);
C, "loadperf.dll");
// $ffi->BackupPerfRegistryToFileW(szFileName, szCommentString);
// szFileName : LPCWSTR
// szCommentString : LPCWSTR optional
// 構造体/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 Loadperf extends StdCallLibrary {
    Loadperf INSTANCE = Native.load("loadperf", Loadperf.class);
    int BackupPerfRegistryToFileW(
        WString szFileName,   // LPCWSTR
        WString szCommentString   // LPCWSTR optional
    );
}
@[Link("loadperf")]
lib Libloadperf
  fun BackupPerfRegistryToFileW = BackupPerfRegistryToFileW(
    szFileName : UInt16*,   # LPCWSTR
    szCommentString : UInt16*   # LPCWSTR optional
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef BackupPerfRegistryToFileWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>);
typedef BackupPerfRegistryToFileWDart = int Function(Pointer<Utf16>, Pointer<Utf16>);
final BackupPerfRegistryToFileW = DynamicLibrary.open('loadperf.dll')
    .lookupFunction<BackupPerfRegistryToFileWNative, BackupPerfRegistryToFileWDart>('BackupPerfRegistryToFileW');
// szFileName : LPCWSTR -> Pointer<Utf16>
// szCommentString : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BackupPerfRegistryToFileW(
  szFileName: PWideChar;   // LPCWSTR
  szCommentString: PWideChar   // LPCWSTR optional
): DWORD; stdcall;
  external 'loadperf.dll' name 'BackupPerfRegistryToFileW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BackupPerfRegistryToFileW"
  c_BackupPerfRegistryToFileW :: CWString -> CWString -> IO Word32
-- szFileName : LPCWSTR -> CWString
-- szCommentString : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let backupperfregistrytofilew =
  foreign "BackupPerfRegistryToFileW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* szFileName : LPCWSTR -> (ptr uint16_t) *)
(* szCommentString : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library loadperf (t "loadperf.dll"))
(cffi:use-foreign-library loadperf)

(cffi:defcfun ("BackupPerfRegistryToFileW" backup-perf-registry-to-file-w :convention :stdcall) :uint32
  (sz-file-name (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-comment-string (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BackupPerfRegistryToFileW = Win32::API::More->new('loadperf',
    'DWORD BackupPerfRegistryToFileW(LPCWSTR szFileName, LPCWSTR szCommentString)');
# my $ret = $BackupPerfRegistryToFileW->Call($szFileName, $szCommentString);
# szFileName : LPCWSTR -> LPCWSTR
# szCommentString : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。