ホーム › Globalization › MappingGetServices
MappingGetServices
関数利用可能なELS言語サービスの一覧を取得する。
シグネチャ
// elscore.dll
#include <windows.h>
HRESULT MappingGetServices(
MAPPING_ENUM_OPTIONS* pOptions, // optional
MAPPING_SERVICE_INFO** prgServices,
DWORD* pdwServicesCount
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pOptions | MAPPING_ENUM_OPTIONS* | inoptional | サービスの列挙時に使用する条件を含む MAPPING_ENUM_OPTIONS 構造体へのポインターです。インストールされているすべてのサービスを取得するには、アプリケーションはこのパラメーターに NULL を指定します。 |
| prgServices | MAPPING_SERVICE_INFO** | out | pOptions パラメーターで指定した条件に一致するサービス情報を含む MAPPING_SERVICE_INFO 構造体の配列へのポインターのアドレスです。 |
| pdwServicesCount | DWORD* | out | 取得されたサービスの数をこの関数が格納する DWORD 変数へのポインターです。 |
戻り値の型: HRESULT
公式ドキュメント
アプリケーションが指定した条件に従って、利用可能な ELS プラットフォームでサポートされるサービスの一覧と、それに関連する情報を取得します。
戻り値
成功した場合は S_OK を返します。成功しなかった場合、この関数はエラーの HRESULT 値を返します。
Note アプリケーションは、それ以降の操作を続行する前に、いかなる失敗もテストする必要があります。
解説(Remarks)
ELS アプリケーションは、すべてのサービスを取得するか、指定したオプションに従ってサービスを絞り込むことができます。関連する手順とコードサンプルについては、Enumerating and Freeing Services を参照してください。
リソースリークを回避するため、アプリケーションは MappingFreeServices を呼び出して、prgServices が指すポインターを解放する必要があります。
パフォーマンス上の理由から、サービスの取得は頻繁に行わないことを推奨します。たとえば、アプリケーションが GUID で特定のサービスを必要とする場合、必要なときに列挙し、今後の使用のためにキャッシュしておくことができます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// elscore.dll
#include <windows.h>
HRESULT MappingGetServices(
MAPPING_ENUM_OPTIONS* pOptions, // optional
MAPPING_SERVICE_INFO** prgServices,
DWORD* pdwServicesCount
);[DllImport("elscore.dll", ExactSpelling = true)]
static extern int MappingGetServices(
IntPtr pOptions, // MAPPING_ENUM_OPTIONS* optional
IntPtr prgServices, // MAPPING_SERVICE_INFO** out
out uint pdwServicesCount // DWORD* out
);<DllImport("elscore.dll", ExactSpelling:=True)>
Public Shared Function MappingGetServices(
pOptions As IntPtr, ' MAPPING_ENUM_OPTIONS* optional
prgServices As IntPtr, ' MAPPING_SERVICE_INFO** out
<Out> ByRef pdwServicesCount As UInteger ' DWORD* out
) As Integer
End Function' pOptions : MAPPING_ENUM_OPTIONS* optional
' prgServices : MAPPING_SERVICE_INFO** out
' pdwServicesCount : DWORD* out
Declare PtrSafe Function MappingGetServices Lib "elscore" ( _
ByVal pOptions As LongPtr, _
ByVal prgServices As LongPtr, _
ByRef pdwServicesCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MappingGetServices = ctypes.windll.elscore.MappingGetServices
MappingGetServices.restype = ctypes.c_int
MappingGetServices.argtypes = [
ctypes.c_void_p, # pOptions : MAPPING_ENUM_OPTIONS* optional
ctypes.c_void_p, # prgServices : MAPPING_SERVICE_INFO** out
ctypes.POINTER(wintypes.DWORD), # pdwServicesCount : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('elscore.dll')
MappingGetServices = Fiddle::Function.new(
lib['MappingGetServices'],
[
Fiddle::TYPE_VOIDP, # pOptions : MAPPING_ENUM_OPTIONS* optional
Fiddle::TYPE_VOIDP, # prgServices : MAPPING_SERVICE_INFO** out
Fiddle::TYPE_VOIDP, # pdwServicesCount : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "elscore")]
extern "system" {
fn MappingGetServices(
pOptions: *mut MAPPING_ENUM_OPTIONS, // MAPPING_ENUM_OPTIONS* optional
prgServices: *mut *mut MAPPING_SERVICE_INFO, // MAPPING_SERVICE_INFO** out
pdwServicesCount: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("elscore.dll")]
public static extern int MappingGetServices(IntPtr pOptions, IntPtr prgServices, out uint pdwServicesCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'elscore_MappingGetServices' -Namespace Win32 -PassThru
# $api::MappingGetServices(pOptions, prgServices, pdwServicesCount)#uselib "elscore.dll"
#func global MappingGetServices "MappingGetServices" sptr, sptr, sptr
; MappingGetServices varptr(pOptions), varptr(prgServices), varptr(pdwServicesCount) ; 戻り値は stat
; pOptions : MAPPING_ENUM_OPTIONS* optional -> "sptr"
; prgServices : MAPPING_SERVICE_INFO** out -> "sptr"
; pdwServicesCount : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "elscore.dll" #cfunc global MappingGetServices "MappingGetServices" var, var, var ; res = MappingGetServices(pOptions, prgServices, pdwServicesCount) ; pOptions : MAPPING_ENUM_OPTIONS* optional -> "var" ; prgServices : MAPPING_SERVICE_INFO** out -> "var" ; pdwServicesCount : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "elscore.dll" #cfunc global MappingGetServices "MappingGetServices" sptr, sptr, sptr ; res = MappingGetServices(varptr(pOptions), varptr(prgServices), varptr(pdwServicesCount)) ; pOptions : MAPPING_ENUM_OPTIONS* optional -> "sptr" ; prgServices : MAPPING_SERVICE_INFO** out -> "sptr" ; pdwServicesCount : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MappingGetServices(MAPPING_ENUM_OPTIONS* pOptions, MAPPING_SERVICE_INFO** prgServices, DWORD* pdwServicesCount) #uselib "elscore.dll" #cfunc global MappingGetServices "MappingGetServices" var, var, var ; res = MappingGetServices(pOptions, prgServices, pdwServicesCount) ; pOptions : MAPPING_ENUM_OPTIONS* optional -> "var" ; prgServices : MAPPING_SERVICE_INFO** out -> "var" ; pdwServicesCount : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MappingGetServices(MAPPING_ENUM_OPTIONS* pOptions, MAPPING_SERVICE_INFO** prgServices, DWORD* pdwServicesCount) #uselib "elscore.dll" #cfunc global MappingGetServices "MappingGetServices" intptr, intptr, intptr ; res = MappingGetServices(varptr(pOptions), varptr(prgServices), varptr(pdwServicesCount)) ; pOptions : MAPPING_ENUM_OPTIONS* optional -> "intptr" ; prgServices : MAPPING_SERVICE_INFO** out -> "intptr" ; pdwServicesCount : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
elscore = windows.NewLazySystemDLL("elscore.dll")
procMappingGetServices = elscore.NewProc("MappingGetServices")
)
// pOptions (MAPPING_ENUM_OPTIONS* optional), prgServices (MAPPING_SERVICE_INFO** out), pdwServicesCount (DWORD* out)
r1, _, err := procMappingGetServices.Call(
uintptr(pOptions),
uintptr(prgServices),
uintptr(pdwServicesCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MappingGetServices(
pOptions: Pointer; // MAPPING_ENUM_OPTIONS* optional
prgServices: Pointer; // MAPPING_SERVICE_INFO** out
pdwServicesCount: Pointer // DWORD* out
): Integer; stdcall;
external 'elscore.dll' name 'MappingGetServices';result := DllCall("elscore\MappingGetServices"
, "Ptr", pOptions ; MAPPING_ENUM_OPTIONS* optional
, "Ptr", prgServices ; MAPPING_SERVICE_INFO** out
, "Ptr", pdwServicesCount ; DWORD* out
, "Int") ; return: HRESULT●MappingGetServices(pOptions, prgServices, pdwServicesCount) = DLL("elscore.dll", "int MappingGetServices(void*, void*, void*)")
# 呼び出し: MappingGetServices(pOptions, prgServices, pdwServicesCount)
# pOptions : MAPPING_ENUM_OPTIONS* optional -> "void*"
# prgServices : MAPPING_SERVICE_INFO** out -> "void*"
# pdwServicesCount : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "elscore" fn MappingGetServices(
pOptions: [*c]MAPPING_ENUM_OPTIONS, // MAPPING_ENUM_OPTIONS* optional
prgServices: [*c][*c]MAPPING_SERVICE_INFO, // MAPPING_SERVICE_INFO** out
pdwServicesCount: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc MappingGetServices(
pOptions: ptr MAPPING_ENUM_OPTIONS, # MAPPING_ENUM_OPTIONS* optional
prgServices: ptr MAPPING_SERVICE_INFO, # MAPPING_SERVICE_INFO** out
pdwServicesCount: ptr uint32 # DWORD* out
): int32 {.importc: "MappingGetServices", stdcall, dynlib: "elscore.dll".}pragma(lib, "elscore");
extern(Windows)
int MappingGetServices(
MAPPING_ENUM_OPTIONS* pOptions, // MAPPING_ENUM_OPTIONS* optional
MAPPING_SERVICE_INFO** prgServices, // MAPPING_SERVICE_INFO** out
uint* pdwServicesCount // DWORD* out
);ccall((:MappingGetServices, "elscore.dll"), stdcall, Int32,
(Ptr{MAPPING_ENUM_OPTIONS}, Ptr{MAPPING_SERVICE_INFO}, Ptr{UInt32}),
pOptions, prgServices, pdwServicesCount)
# pOptions : MAPPING_ENUM_OPTIONS* optional -> Ptr{MAPPING_ENUM_OPTIONS}
# prgServices : MAPPING_SERVICE_INFO** out -> Ptr{MAPPING_SERVICE_INFO}
# pdwServicesCount : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MappingGetServices(
void* pOptions,
void* prgServices,
uint32_t* pdwServicesCount);
]]
local elscore = ffi.load("elscore")
-- elscore.MappingGetServices(pOptions, prgServices, pdwServicesCount)
-- pOptions : MAPPING_ENUM_OPTIONS* optional
-- prgServices : MAPPING_SERVICE_INFO** out
-- pdwServicesCount : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('elscore.dll');
const MappingGetServices = lib.func('__stdcall', 'MappingGetServices', 'int32_t', ['void *', 'void *', 'uint32_t *']);
// MappingGetServices(pOptions, prgServices, pdwServicesCount)
// pOptions : MAPPING_ENUM_OPTIONS* optional -> 'void *'
// prgServices : MAPPING_SERVICE_INFO** out -> 'void *'
// pdwServicesCount : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("elscore.dll", {
MappingGetServices: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MappingGetServices(pOptions, prgServices, pdwServicesCount)
// pOptions : MAPPING_ENUM_OPTIONS* optional -> "pointer"
// prgServices : MAPPING_SERVICE_INFO** out -> "pointer"
// pdwServicesCount : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MappingGetServices(
void* pOptions,
void* prgServices,
uint32_t* pdwServicesCount);
C, "elscore.dll");
// $ffi->MappingGetServices(pOptions, prgServices, pdwServicesCount);
// pOptions : MAPPING_ENUM_OPTIONS* optional
// prgServices : MAPPING_SERVICE_INFO** out
// pdwServicesCount : DWORD* 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 Elscore extends StdCallLibrary {
Elscore INSTANCE = Native.load("elscore", Elscore.class);
int MappingGetServices(
Pointer pOptions, // MAPPING_ENUM_OPTIONS* optional
Pointer prgServices, // MAPPING_SERVICE_INFO** out
IntByReference pdwServicesCount // DWORD* out
);
}@[Link("elscore")]
lib Libelscore
fun MappingGetServices = MappingGetServices(
pOptions : MAPPING_ENUM_OPTIONS*, # MAPPING_ENUM_OPTIONS* optional
prgServices : MAPPING_SERVICE_INFO**, # MAPPING_SERVICE_INFO** out
pdwServicesCount : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MappingGetServicesNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef MappingGetServicesDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final MappingGetServices = DynamicLibrary.open('elscore.dll')
.lookupFunction<MappingGetServicesNative, MappingGetServicesDart>('MappingGetServices');
// pOptions : MAPPING_ENUM_OPTIONS* optional -> Pointer<Void>
// prgServices : MAPPING_SERVICE_INFO** out -> Pointer<Void>
// pdwServicesCount : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MappingGetServices(
pOptions: Pointer; // MAPPING_ENUM_OPTIONS* optional
prgServices: Pointer; // MAPPING_SERVICE_INFO** out
pdwServicesCount: Pointer // DWORD* out
): Integer; stdcall;
external 'elscore.dll' name 'MappingGetServices';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MappingGetServices"
c_MappingGetServices :: Ptr () -> Ptr () -> Ptr Word32 -> IO Int32
-- pOptions : MAPPING_ENUM_OPTIONS* optional -> Ptr ()
-- prgServices : MAPPING_SERVICE_INFO** out -> Ptr ()
-- pdwServicesCount : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mappinggetservices =
foreign "MappingGetServices"
((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* pOptions : MAPPING_ENUM_OPTIONS* optional -> (ptr void) *)
(* prgServices : MAPPING_SERVICE_INFO** out -> (ptr void) *)
(* pdwServicesCount : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library elscore (t "elscore.dll"))
(cffi:use-foreign-library elscore)
(cffi:defcfun ("MappingGetServices" mapping-get-services :convention :stdcall) :int32
(p-options :pointer) ; MAPPING_ENUM_OPTIONS* optional
(prg-services :pointer) ; MAPPING_SERVICE_INFO** out
(pdw-services-count :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MappingGetServices = Win32::API::More->new('elscore',
'int MappingGetServices(LPVOID pOptions, LPVOID prgServices, LPVOID pdwServicesCount)');
# my $ret = $MappingGetServices->Call($pOptions, $prgServices, $pdwServicesCount);
# pOptions : MAPPING_ENUM_OPTIONS* optional -> LPVOID
# prgServices : MAPPING_SERVICE_INFO** out -> LPVOID
# pdwServicesCount : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f MappingFreeServices — MappingGetServicesで取得したサービス情報を解放する。