ホーム › System.Performance › UnloadPerfCounterTextStringsA
UnloadPerfCounterTextStringsA
関数パフォーマンスカウンタのテキスト文字列を削除する。ANSI版。
シグネチャ
// loadperf.dll (ANSI / -A)
#include <windows.h>
DWORD UnloadPerfCounterTextStringsA(
LPSTR lpCommandLine,
BOOL bQuietModeArg
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpCommandLine | LPSTR | in | 1 文字以上の任意の文字、スペース、続いてアプリケーション名で構成される、null 終端文字列です。アプリケーション名は、テキスト文字列の読み込みに使用した初期化 (.ini) ファイル内の drivername キー値と一致する必要があります。 |
| bQuietModeArg | BOOL | in | Unlodctr ツールの出力を表示しないようにするには TRUE を指定します。それ以外の場合は FALSE を指定します。このパラメーターは、アプリケーションをコマンドプロンプトから実行した場合にのみ意味を持ちます。 |
戻り値の型: DWORD
公式ドキュメント
指定したアプリケーションのパフォーマンスオブジェクトとカウンターをコンピューターからアンロードします。(ANSI)
戻り値
関数が成功した場合、戻り値は ERROR_SUCCESS です。
関数が失敗した場合、戻り値は システムエラーコードのいずれかです。
解説(Remarks)
この関数は、Unlodctr ツールが提供する機能への API を提供します。詳細については、Removing Counter Names and Descriptions from the Registry を参照してください。
メモ
loadperf.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして UnloadPerfCounterTextStrings を定義します。このエンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、コンパイルエラーや実行時エラーの原因となる不整合が生じる可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// loadperf.dll (ANSI / -A)
#include <windows.h>
DWORD UnloadPerfCounterTextStringsA(
LPSTR lpCommandLine,
BOOL bQuietModeArg
);[DllImport("loadperf.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint UnloadPerfCounterTextStringsA(
[MarshalAs(UnmanagedType.LPStr)] string lpCommandLine, // LPSTR
bool bQuietModeArg // BOOL
);<DllImport("loadperf.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UnloadPerfCounterTextStringsA(
<MarshalAs(UnmanagedType.LPStr)> lpCommandLine As String, ' LPSTR
bQuietModeArg As Boolean ' BOOL
) As UInteger
End Function' lpCommandLine : LPSTR
' bQuietModeArg : BOOL
Declare PtrSafe Function UnloadPerfCounterTextStringsA Lib "loadperf" ( _
ByVal lpCommandLine As String, _
ByVal bQuietModeArg As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UnloadPerfCounterTextStringsA = ctypes.windll.loadperf.UnloadPerfCounterTextStringsA
UnloadPerfCounterTextStringsA.restype = wintypes.DWORD
UnloadPerfCounterTextStringsA.argtypes = [
wintypes.LPCSTR, # lpCommandLine : LPSTR
wintypes.BOOL, # bQuietModeArg : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('loadperf.dll')
UnloadPerfCounterTextStringsA = Fiddle::Function.new(
lib['UnloadPerfCounterTextStringsA'],
[
Fiddle::TYPE_VOIDP, # lpCommandLine : LPSTR
Fiddle::TYPE_INT, # bQuietModeArg : BOOL
],
-Fiddle::TYPE_INT)#[link(name = "loadperf")]
extern "system" {
fn UnloadPerfCounterTextStringsA(
lpCommandLine: *mut u8, // LPSTR
bQuietModeArg: i32 // BOOL
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("loadperf.dll", CharSet = CharSet.Ansi)]
public static extern uint UnloadPerfCounterTextStringsA([MarshalAs(UnmanagedType.LPStr)] string lpCommandLine, bool bQuietModeArg);
"@
$api = Add-Type -MemberDefinition $sig -Name 'loadperf_UnloadPerfCounterTextStringsA' -Namespace Win32 -PassThru
# $api::UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)#uselib "loadperf.dll"
#func global UnloadPerfCounterTextStringsA "UnloadPerfCounterTextStringsA" sptr, sptr
; UnloadPerfCounterTextStringsA lpCommandLine, bQuietModeArg ; 戻り値は stat
; lpCommandLine : LPSTR -> "sptr"
; bQuietModeArg : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "loadperf.dll"
#cfunc global UnloadPerfCounterTextStringsA "UnloadPerfCounterTextStringsA" str, int
; res = UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
; lpCommandLine : LPSTR -> "str"
; bQuietModeArg : BOOL -> "int"; DWORD UnloadPerfCounterTextStringsA(LPSTR lpCommandLine, BOOL bQuietModeArg)
#uselib "loadperf.dll"
#cfunc global UnloadPerfCounterTextStringsA "UnloadPerfCounterTextStringsA" str, int
; res = UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
; lpCommandLine : LPSTR -> "str"
; bQuietModeArg : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
loadperf = windows.NewLazySystemDLL("loadperf.dll")
procUnloadPerfCounterTextStringsA = loadperf.NewProc("UnloadPerfCounterTextStringsA")
)
// lpCommandLine (LPSTR), bQuietModeArg (BOOL)
r1, _, err := procUnloadPerfCounterTextStringsA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpCommandLine))),
uintptr(bQuietModeArg),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction UnloadPerfCounterTextStringsA(
lpCommandLine: PAnsiChar; // LPSTR
bQuietModeArg: BOOL // BOOL
): DWORD; stdcall;
external 'loadperf.dll' name 'UnloadPerfCounterTextStringsA';result := DllCall("loadperf\UnloadPerfCounterTextStringsA"
, "AStr", lpCommandLine ; LPSTR
, "Int", bQuietModeArg ; BOOL
, "UInt") ; return: DWORD●UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg) = DLL("loadperf.dll", "dword UnloadPerfCounterTextStringsA(char*, bool)")
# 呼び出し: UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
# lpCommandLine : LPSTR -> "char*"
# bQuietModeArg : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "loadperf" fn UnloadPerfCounterTextStringsA(
lpCommandLine: [*c]const u8, // LPSTR
bQuietModeArg: i32 // BOOL
) callconv(std.os.windows.WINAPI) u32;proc UnloadPerfCounterTextStringsA(
lpCommandLine: cstring, # LPSTR
bQuietModeArg: int32 # BOOL
): uint32 {.importc: "UnloadPerfCounterTextStringsA", stdcall, dynlib: "loadperf.dll".}pragma(lib, "loadperf");
extern(Windows)
uint UnloadPerfCounterTextStringsA(
const(char)* lpCommandLine, // LPSTR
int bQuietModeArg // BOOL
);ccall((:UnloadPerfCounterTextStringsA, "loadperf.dll"), stdcall, UInt32,
(Cstring, Int32),
lpCommandLine, bQuietModeArg)
# lpCommandLine : LPSTR -> Cstring
# bQuietModeArg : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t UnloadPerfCounterTextStringsA(
const char* lpCommandLine,
int32_t bQuietModeArg);
]]
local loadperf = ffi.load("loadperf")
-- loadperf.UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
-- lpCommandLine : LPSTR
-- bQuietModeArg : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('loadperf.dll');
const UnloadPerfCounterTextStringsA = lib.func('__stdcall', 'UnloadPerfCounterTextStringsA', 'uint32_t', ['str', 'int32_t']);
// UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
// lpCommandLine : LPSTR -> 'str'
// bQuietModeArg : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("loadperf.dll", {
UnloadPerfCounterTextStringsA: { parameters: ["buffer", "i32"], result: "u32" },
});
// lib.symbols.UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg)
// lpCommandLine : LPSTR -> "buffer"
// bQuietModeArg : BOOL -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t UnloadPerfCounterTextStringsA(
const char* lpCommandLine,
int32_t bQuietModeArg);
C, "loadperf.dll");
// $ffi->UnloadPerfCounterTextStringsA(lpCommandLine, bQuietModeArg);
// lpCommandLine : LPSTR
// bQuietModeArg : BOOL
// 構造体/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.ASCII_OPTIONS);
int UnloadPerfCounterTextStringsA(
String lpCommandLine, // LPSTR
boolean bQuietModeArg // BOOL
);
}@[Link("loadperf")]
lib Libloadperf
fun UnloadPerfCounterTextStringsA = UnloadPerfCounterTextStringsA(
lpCommandLine : UInt8*, # LPSTR
bQuietModeArg : Int32 # BOOL
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UnloadPerfCounterTextStringsANative = Uint32 Function(Pointer<Utf8>, Int32);
typedef UnloadPerfCounterTextStringsADart = int Function(Pointer<Utf8>, int);
final UnloadPerfCounterTextStringsA = DynamicLibrary.open('loadperf.dll')
.lookupFunction<UnloadPerfCounterTextStringsANative, UnloadPerfCounterTextStringsADart>('UnloadPerfCounterTextStringsA');
// lpCommandLine : LPSTR -> Pointer<Utf8>
// bQuietModeArg : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UnloadPerfCounterTextStringsA(
lpCommandLine: PAnsiChar; // LPSTR
bQuietModeArg: BOOL // BOOL
): DWORD; stdcall;
external 'loadperf.dll' name 'UnloadPerfCounterTextStringsA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UnloadPerfCounterTextStringsA"
c_UnloadPerfCounterTextStringsA :: CString -> CInt -> IO Word32
-- lpCommandLine : LPSTR -> CString
-- bQuietModeArg : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let unloadperfcountertextstringsa =
foreign "UnloadPerfCounterTextStringsA"
(string @-> int32_t @-> returning uint32_t)
(* lpCommandLine : LPSTR -> string *)
(* bQuietModeArg : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library loadperf (t "loadperf.dll"))
(cffi:use-foreign-library loadperf)
(cffi:defcfun ("UnloadPerfCounterTextStringsA" unload-perf-counter-text-strings-a :convention :stdcall) :uint32
(lp-command-line :string) ; LPSTR
(b-quiet-mode-arg :int32)) ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UnloadPerfCounterTextStringsA = Win32::API::More->new('loadperf',
'DWORD UnloadPerfCounterTextStringsA(LPCSTR lpCommandLine, BOOL bQuietModeArg)');
# my $ret = $UnloadPerfCounterTextStringsA->Call($lpCommandLine, $bQuietModeArg);
# lpCommandLine : LPSTR -> LPCSTR
# bQuietModeArg : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f UnloadPerfCounterTextStringsW (Unicode版) — 登録済みパフォーマンスカウンタのテキスト文字列を削除する。
公式の関連項目
- f LoadPerfCounterTextStringsA — パフォーマンスカウンタの名称と説明テキストを登録する。ANSI版。