ホーム › System.Performance › PdhVerifySQLDBA
PdhVerifySQLDBA
関数SQLデータベースがPDHログ用か検証する(ANSI版)。
シグネチャ
// pdh.dll (ANSI / -A)
#include <windows.h>
DWORD PdhVerifySQLDBA(
LPCSTR szDataSource
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| szDataSource | LPCSTR | in | PDHスキーマの有無を検証するSQLデータソース名(ANSI、ODBC DSN)を指定する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// pdh.dll (ANSI / -A)
#include <windows.h>
DWORD PdhVerifySQLDBA(
LPCSTR szDataSource
);[DllImport("pdh.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint PdhVerifySQLDBA(
[MarshalAs(UnmanagedType.LPStr)] string szDataSource // LPCSTR
);<DllImport("pdh.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PdhVerifySQLDBA(
<MarshalAs(UnmanagedType.LPStr)> szDataSource As String ' LPCSTR
) As UInteger
End Function' szDataSource : LPCSTR
Declare PtrSafe Function PdhVerifySQLDBA Lib "pdh" ( _
ByVal szDataSource As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PdhVerifySQLDBA = ctypes.windll.pdh.PdhVerifySQLDBA
PdhVerifySQLDBA.restype = wintypes.DWORD
PdhVerifySQLDBA.argtypes = [
wintypes.LPCSTR, # szDataSource : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('pdh.dll')
PdhVerifySQLDBA = Fiddle::Function.new(
lib['PdhVerifySQLDBA'],
[
Fiddle::TYPE_VOIDP, # szDataSource : LPCSTR
],
-Fiddle::TYPE_INT)#[link(name = "pdh")]
extern "system" {
fn PdhVerifySQLDBA(
szDataSource: *const u8 // LPCSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Ansi)]
public static extern uint PdhVerifySQLDBA([MarshalAs(UnmanagedType.LPStr)] string szDataSource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhVerifySQLDBA' -Namespace Win32 -PassThru
# $api::PdhVerifySQLDBA(szDataSource)#uselib "pdh.dll"
#func global PdhVerifySQLDBA "PdhVerifySQLDBA" sptr
; PdhVerifySQLDBA szDataSource ; 戻り値は stat
; szDataSource : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "pdh.dll"
#cfunc global PdhVerifySQLDBA "PdhVerifySQLDBA" str
; res = PdhVerifySQLDBA(szDataSource)
; szDataSource : LPCSTR -> "str"; DWORD PdhVerifySQLDBA(LPCSTR szDataSource)
#uselib "pdh.dll"
#cfunc global PdhVerifySQLDBA "PdhVerifySQLDBA" str
; res = PdhVerifySQLDBA(szDataSource)
; szDataSource : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
pdh = windows.NewLazySystemDLL("pdh.dll")
procPdhVerifySQLDBA = pdh.NewProc("PdhVerifySQLDBA")
)
// szDataSource (LPCSTR)
r1, _, err := procPdhVerifySQLDBA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szDataSource))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PdhVerifySQLDBA(
szDataSource: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'pdh.dll' name 'PdhVerifySQLDBA';result := DllCall("pdh\PdhVerifySQLDBA"
, "AStr", szDataSource ; LPCSTR
, "UInt") ; return: DWORD●PdhVerifySQLDBA(szDataSource) = DLL("pdh.dll", "dword PdhVerifySQLDBA(char*)")
# 呼び出し: PdhVerifySQLDBA(szDataSource)
# szDataSource : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "pdh" fn PdhVerifySQLDBA(
szDataSource: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) u32;proc PdhVerifySQLDBA(
szDataSource: cstring # LPCSTR
): uint32 {.importc: "PdhVerifySQLDBA", stdcall, dynlib: "pdh.dll".}pragma(lib, "pdh");
extern(Windows)
uint PdhVerifySQLDBA(
const(char)* szDataSource // LPCSTR
);ccall((:PdhVerifySQLDBA, "pdh.dll"), stdcall, UInt32,
(Cstring,),
szDataSource)
# szDataSource : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PdhVerifySQLDBA(
const char* szDataSource);
]]
local pdh = ffi.load("pdh")
-- pdh.PdhVerifySQLDBA(szDataSource)
-- szDataSource : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('pdh.dll');
const PdhVerifySQLDBA = lib.func('__stdcall', 'PdhVerifySQLDBA', 'uint32_t', ['str']);
// PdhVerifySQLDBA(szDataSource)
// szDataSource : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("pdh.dll", {
PdhVerifySQLDBA: { parameters: ["buffer"], result: "u32" },
});
// lib.symbols.PdhVerifySQLDBA(szDataSource)
// szDataSource : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PdhVerifySQLDBA(
const char* szDataSource);
C, "pdh.dll");
// $ffi->PdhVerifySQLDBA(szDataSource);
// szDataSource : LPCSTR
// 構造体/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 Pdh extends StdCallLibrary {
Pdh INSTANCE = Native.load("pdh", Pdh.class, W32APIOptions.ASCII_OPTIONS);
int PdhVerifySQLDBA(
String szDataSource // LPCSTR
);
}@[Link("pdh")]
lib Libpdh
fun PdhVerifySQLDBA = PdhVerifySQLDBA(
szDataSource : UInt8* # LPCSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PdhVerifySQLDBANative = Uint32 Function(Pointer<Utf8>);
typedef PdhVerifySQLDBADart = int Function(Pointer<Utf8>);
final PdhVerifySQLDBA = DynamicLibrary.open('pdh.dll')
.lookupFunction<PdhVerifySQLDBANative, PdhVerifySQLDBADart>('PdhVerifySQLDBA');
// szDataSource : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PdhVerifySQLDBA(
szDataSource: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'pdh.dll' name 'PdhVerifySQLDBA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PdhVerifySQLDBA"
c_PdhVerifySQLDBA :: CString -> IO Word32
-- szDataSource : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pdhverifysqldba =
foreign "PdhVerifySQLDBA"
(string @-> returning uint32_t)
(* szDataSource : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library pdh (t "pdh.dll"))
(cffi:use-foreign-library pdh)
(cffi:defcfun ("PdhVerifySQLDBA" pdh-verify-sqldba :convention :stdcall) :uint32
(sz-data-source :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PdhVerifySQLDBA = Win32::API::More->new('pdh',
'DWORD PdhVerifySQLDBA(LPCSTR szDataSource)');
# my $ret = $PdhVerifySQLDBA->Call($szDataSource);
# szDataSource : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f PdhVerifySQLDBW (Unicode版) — SQLデータベースがPDHログ用に適切か検証する。