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

UpdatePerfNameFilesW

関数
パフォーマンスカウンタの名称およびヘルプファイルを更新する。
DLLloadperf.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// loadperf.dll  (Unicode / -W)
#include <windows.h>

DWORD UpdatePerfNameFilesW(
    LPCWSTR szNewCtrFilePath,
    LPCWSTR szNewHlpFilePath,   // optional
    LPWSTR szLanguageID,
    UINT_PTR dwModes
);

パラメーター

名前方向説明
szNewCtrFilePathLPCWSTRin新しいカウンター名ファイル(.ini)のパス。
szNewHlpFilePathLPCWSTRinoptional新しい説明テキストファイルのパス。
szLanguageIDLPWSTRin対象言語を示す言語ID文字列。
dwModesUINT_PTRin更新モードを制御するフラグ値。

戻り値の型: DWORD

各言語での呼び出し定義

// loadperf.dll  (Unicode / -W)
#include <windows.h>

DWORD UpdatePerfNameFilesW(
    LPCWSTR szNewCtrFilePath,
    LPCWSTR szNewHlpFilePath,   // optional
    LPWSTR szLanguageID,
    UINT_PTR dwModes
);
[DllImport("loadperf.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint UpdatePerfNameFilesW(
    [MarshalAs(UnmanagedType.LPWStr)] string szNewCtrFilePath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szNewHlpFilePath,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szLanguageID,   // LPWSTR
    UIntPtr dwModes   // UINT_PTR
);
<DllImport("loadperf.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UpdatePerfNameFilesW(
    <MarshalAs(UnmanagedType.LPWStr)> szNewCtrFilePath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szNewHlpFilePath As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> szLanguageID As String,   ' LPWSTR
    dwModes As UIntPtr   ' UINT_PTR
) As UInteger
End Function
' szNewCtrFilePath : LPCWSTR
' szNewHlpFilePath : LPCWSTR optional
' szLanguageID : LPWSTR
' dwModes : UINT_PTR
Declare PtrSafe Function UpdatePerfNameFilesW Lib "loadperf" ( _
    ByVal szNewCtrFilePath As LongPtr, _
    ByVal szNewHlpFilePath As LongPtr, _
    ByVal szLanguageID As LongPtr, _
    ByVal dwModes As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UpdatePerfNameFilesW = ctypes.windll.loadperf.UpdatePerfNameFilesW
UpdatePerfNameFilesW.restype = wintypes.DWORD
UpdatePerfNameFilesW.argtypes = [
    wintypes.LPCWSTR,  # szNewCtrFilePath : LPCWSTR
    wintypes.LPCWSTR,  # szNewHlpFilePath : LPCWSTR optional
    wintypes.LPCWSTR,  # szLanguageID : LPWSTR
    ctypes.c_size_t,  # dwModes : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('loadperf.dll')
UpdatePerfNameFilesW = Fiddle::Function.new(
  lib['UpdatePerfNameFilesW'],
  [
    Fiddle::TYPE_VOIDP,  # szNewCtrFilePath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szNewHlpFilePath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # szLanguageID : LPWSTR
    Fiddle::TYPE_UINTPTR_T,  # dwModes : UINT_PTR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "loadperf")]
extern "system" {
    fn UpdatePerfNameFilesW(
        szNewCtrFilePath: *const u16,  // LPCWSTR
        szNewHlpFilePath: *const u16,  // LPCWSTR optional
        szLanguageID: *mut u16,  // LPWSTR
        dwModes: usize  // UINT_PTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("loadperf.dll", CharSet = CharSet.Unicode)]
public static extern uint UpdatePerfNameFilesW([MarshalAs(UnmanagedType.LPWStr)] string szNewCtrFilePath, [MarshalAs(UnmanagedType.LPWStr)] string szNewHlpFilePath, [MarshalAs(UnmanagedType.LPWStr)] string szLanguageID, UIntPtr dwModes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'loadperf_UpdatePerfNameFilesW' -Namespace Win32 -PassThru
# $api::UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
#uselib "loadperf.dll"
#func global UpdatePerfNameFilesW "UpdatePerfNameFilesW" wptr, wptr, wptr, wptr
; UpdatePerfNameFilesW szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes   ; 戻り値は stat
; szNewCtrFilePath : LPCWSTR -> "wptr"
; szNewHlpFilePath : LPCWSTR optional -> "wptr"
; szLanguageID : LPWSTR -> "wptr"
; dwModes : UINT_PTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "loadperf.dll"
#cfunc global UpdatePerfNameFilesW "UpdatePerfNameFilesW" wstr, wstr, wstr, sptr
; res = UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
; szNewCtrFilePath : LPCWSTR -> "wstr"
; szNewHlpFilePath : LPCWSTR optional -> "wstr"
; szLanguageID : LPWSTR -> "wstr"
; dwModes : UINT_PTR -> "sptr"
; DWORD UpdatePerfNameFilesW(LPCWSTR szNewCtrFilePath, LPCWSTR szNewHlpFilePath, LPWSTR szLanguageID, UINT_PTR dwModes)
#uselib "loadperf.dll"
#cfunc global UpdatePerfNameFilesW "UpdatePerfNameFilesW" wstr, wstr, wstr, intptr
; res = UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
; szNewCtrFilePath : LPCWSTR -> "wstr"
; szNewHlpFilePath : LPCWSTR optional -> "wstr"
; szLanguageID : LPWSTR -> "wstr"
; dwModes : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	loadperf = windows.NewLazySystemDLL("loadperf.dll")
	procUpdatePerfNameFilesW = loadperf.NewProc("UpdatePerfNameFilesW")
)

// szNewCtrFilePath (LPCWSTR), szNewHlpFilePath (LPCWSTR optional), szLanguageID (LPWSTR), dwModes (UINT_PTR)
r1, _, err := procUpdatePerfNameFilesW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szNewCtrFilePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szNewHlpFilePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szLanguageID))),
	uintptr(dwModes),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function UpdatePerfNameFilesW(
  szNewCtrFilePath: PWideChar;   // LPCWSTR
  szNewHlpFilePath: PWideChar;   // LPCWSTR optional
  szLanguageID: PWideChar;   // LPWSTR
  dwModes: NativeUInt   // UINT_PTR
): DWORD; stdcall;
  external 'loadperf.dll' name 'UpdatePerfNameFilesW';
result := DllCall("loadperf\UpdatePerfNameFilesW"
    , "WStr", szNewCtrFilePath   ; LPCWSTR
    , "WStr", szNewHlpFilePath   ; LPCWSTR optional
    , "WStr", szLanguageID   ; LPWSTR
    , "UPtr", dwModes   ; UINT_PTR
    , "UInt")   ; return: DWORD
●UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes) = DLL("loadperf.dll", "dword UpdatePerfNameFilesW(char*, char*, char*, int)")
# 呼び出し: UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
# szNewCtrFilePath : LPCWSTR -> "char*"
# szNewHlpFilePath : LPCWSTR optional -> "char*"
# szLanguageID : LPWSTR -> "char*"
# dwModes : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "loadperf" fn UpdatePerfNameFilesW(
    szNewCtrFilePath: [*c]const u16, // LPCWSTR
    szNewHlpFilePath: [*c]const u16, // LPCWSTR optional
    szLanguageID: [*c]const u16, // LPWSTR
    dwModes: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc UpdatePerfNameFilesW(
    szNewCtrFilePath: WideCString,  # LPCWSTR
    szNewHlpFilePath: WideCString,  # LPCWSTR optional
    szLanguageID: WideCString,  # LPWSTR
    dwModes: uint  # UINT_PTR
): uint32 {.importc: "UpdatePerfNameFilesW", stdcall, dynlib: "loadperf.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "loadperf");
extern(Windows)
uint UpdatePerfNameFilesW(
    const(wchar)* szNewCtrFilePath,   // LPCWSTR
    const(wchar)* szNewHlpFilePath,   // LPCWSTR optional
    const(wchar)* szLanguageID,   // LPWSTR
    size_t dwModes   // UINT_PTR
);
ccall((:UpdatePerfNameFilesW, "loadperf.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, Cwstring, Csize_t),
      szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
# szNewCtrFilePath : LPCWSTR -> Cwstring
# szNewHlpFilePath : LPCWSTR optional -> Cwstring
# szLanguageID : LPWSTR -> Cwstring
# dwModes : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t UpdatePerfNameFilesW(
    const uint16_t* szNewCtrFilePath,
    const uint16_t* szNewHlpFilePath,
    const uint16_t* szLanguageID,
    uintptr_t dwModes);
]]
local loadperf = ffi.load("loadperf")
-- loadperf.UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
-- szNewCtrFilePath : LPCWSTR
-- szNewHlpFilePath : LPCWSTR optional
-- szLanguageID : LPWSTR
-- dwModes : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('loadperf.dll');
const UpdatePerfNameFilesW = lib.func('__stdcall', 'UpdatePerfNameFilesW', 'uint32_t', ['str16', 'str16', 'str16', 'uintptr_t']);
// UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
// szNewCtrFilePath : LPCWSTR -> 'str16'
// szNewHlpFilePath : LPCWSTR optional -> 'str16'
// szLanguageID : LPWSTR -> 'str16'
// dwModes : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("loadperf.dll", {
  UpdatePerfNameFilesW: { parameters: ["buffer", "buffer", "buffer", "usize"], result: "u32" },
});
// lib.symbols.UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes)
// szNewCtrFilePath : LPCWSTR -> "buffer"
// szNewHlpFilePath : LPCWSTR optional -> "buffer"
// szLanguageID : LPWSTR -> "buffer"
// dwModes : UINT_PTR -> "usize"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t UpdatePerfNameFilesW(
    const uint16_t* szNewCtrFilePath,
    const uint16_t* szNewHlpFilePath,
    const uint16_t* szLanguageID,
    size_t dwModes);
C, "loadperf.dll");
// $ffi->UpdatePerfNameFilesW(szNewCtrFilePath, szNewHlpFilePath, szLanguageID, dwModes);
// szNewCtrFilePath : LPCWSTR
// szNewHlpFilePath : LPCWSTR optional
// szLanguageID : LPWSTR
// dwModes : UINT_PTR
// 構造体/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, W32APIOptions.UNICODE_OPTIONS);
    int UpdatePerfNameFilesW(
        WString szNewCtrFilePath,   // LPCWSTR
        WString szNewHlpFilePath,   // LPCWSTR optional
        WString szLanguageID,   // LPWSTR
        long dwModes   // UINT_PTR
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("loadperf")]
lib Libloadperf
  fun UpdatePerfNameFilesW = UpdatePerfNameFilesW(
    szNewCtrFilePath : UInt16*,   # LPCWSTR
    szNewHlpFilePath : UInt16*,   # LPCWSTR optional
    szLanguageID : UInt16*,   # LPWSTR
    dwModes : LibC::SizeT   # UINT_PTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef UpdatePerfNameFilesWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, UintPtr);
typedef UpdatePerfNameFilesWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final UpdatePerfNameFilesW = DynamicLibrary.open('loadperf.dll')
    .lookupFunction<UpdatePerfNameFilesWNative, UpdatePerfNameFilesWDart>('UpdatePerfNameFilesW');
// szNewCtrFilePath : LPCWSTR -> Pointer<Utf16>
// szNewHlpFilePath : LPCWSTR optional -> Pointer<Utf16>
// szLanguageID : LPWSTR -> Pointer<Utf16>
// dwModes : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function UpdatePerfNameFilesW(
  szNewCtrFilePath: PWideChar;   // LPCWSTR
  szNewHlpFilePath: PWideChar;   // LPCWSTR optional
  szLanguageID: PWideChar;   // LPWSTR
  dwModes: NativeUInt   // UINT_PTR
): DWORD; stdcall;
  external 'loadperf.dll' name 'UpdatePerfNameFilesW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "UpdatePerfNameFilesW"
  c_UpdatePerfNameFilesW :: CWString -> CWString -> CWString -> CUIntPtr -> IO Word32
-- szNewCtrFilePath : LPCWSTR -> CWString
-- szNewHlpFilePath : LPCWSTR optional -> CWString
-- szLanguageID : LPWSTR -> CWString
-- dwModes : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let updateperfnamefilesw =
  foreign "UpdatePerfNameFilesW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> size_t @-> returning uint32_t)
(* szNewCtrFilePath : LPCWSTR -> (ptr uint16_t) *)
(* szNewHlpFilePath : LPCWSTR optional -> (ptr uint16_t) *)
(* szLanguageID : LPWSTR -> (ptr uint16_t) *)
(* dwModes : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library loadperf (t "loadperf.dll"))
(cffi:use-foreign-library loadperf)

(cffi:defcfun ("UpdatePerfNameFilesW" update-perf-name-files-w :convention :stdcall) :uint32
  (sz-new-ctr-file-path (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-new-hlp-file-path (:string :encoding :utf-16le))   ; LPCWSTR optional
  (sz-language-id (:string :encoding :utf-16le))   ; LPWSTR
  (dw-modes :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UpdatePerfNameFilesW = Win32::API::More->new('loadperf',
    'DWORD UpdatePerfNameFilesW(LPCWSTR szNewCtrFilePath, LPCWSTR szNewHlpFilePath, LPCWSTR szLanguageID, WPARAM dwModes)');
# my $ret = $UpdatePerfNameFilesW->Call($szNewCtrFilePath, $szNewHlpFilePath, $szLanguageID, $dwModes);
# szNewCtrFilePath : LPCWSTR -> LPCWSTR
# szNewHlpFilePath : LPCWSTR optional -> LPCWSTR
# szLanguageID : LPWSTR -> LPCWSTR
# dwModes : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い