ホーム › Security.EnterpriseData › SrpGetEnterpriseIds
SrpGetEnterpriseIds
関数トークンに関連付けられた企業IDの一覧を取得する。
シグネチャ
// srpapi.dll
#include <windows.h>
HRESULT SrpGetEnterpriseIds(
HANDLE tokenHandle,
DWORD* numberOfBytes, // optional
LPCWSTR* enterpriseIds, // optional
DWORD* enterpriseIdCount
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| tokenHandle | HANDLE | in | 企業IDを取得する対象のアクセストークンハンドル。NULLで現在のスレッド。 |
| numberOfBytes | DWORD* | inoutoptional | enterpriseIdsバッファのサイズ(バイト)を入出力するポインタ。 |
| enterpriseIds | LPCWSTR* | outoptional | 取得した企業ID文字列群を受け取るバッファへのポインタ。 |
| enterpriseIdCount | DWORD* | out | 返された企業IDの個数を受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// srpapi.dll
#include <windows.h>
HRESULT SrpGetEnterpriseIds(
HANDLE tokenHandle,
DWORD* numberOfBytes, // optional
LPCWSTR* enterpriseIds, // optional
DWORD* enterpriseIdCount
);[DllImport("srpapi.dll", ExactSpelling = true)]
static extern int SrpGetEnterpriseIds(
IntPtr tokenHandle, // HANDLE
IntPtr numberOfBytes, // DWORD* optional, in/out
IntPtr enterpriseIds, // LPCWSTR* optional, out
out uint enterpriseIdCount // DWORD* out
);<DllImport("srpapi.dll", ExactSpelling:=True)>
Public Shared Function SrpGetEnterpriseIds(
tokenHandle As IntPtr, ' HANDLE
numberOfBytes As IntPtr, ' DWORD* optional, in/out
enterpriseIds As IntPtr, ' LPCWSTR* optional, out
<Out> ByRef enterpriseIdCount As UInteger ' DWORD* out
) As Integer
End Function' tokenHandle : HANDLE
' numberOfBytes : DWORD* optional, in/out
' enterpriseIds : LPCWSTR* optional, out
' enterpriseIdCount : DWORD* out
Declare PtrSafe Function SrpGetEnterpriseIds Lib "srpapi" ( _
ByVal tokenHandle As LongPtr, _
ByVal numberOfBytes As LongPtr, _
ByVal enterpriseIds As LongPtr, _
ByRef enterpriseIdCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SrpGetEnterpriseIds = ctypes.windll.srpapi.SrpGetEnterpriseIds
SrpGetEnterpriseIds.restype = ctypes.c_int
SrpGetEnterpriseIds.argtypes = [
wintypes.HANDLE, # tokenHandle : HANDLE
ctypes.POINTER(wintypes.DWORD), # numberOfBytes : DWORD* optional, in/out
ctypes.c_void_p, # enterpriseIds : LPCWSTR* optional, out
ctypes.POINTER(wintypes.DWORD), # enterpriseIdCount : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('srpapi.dll')
SrpGetEnterpriseIds = Fiddle::Function.new(
lib['SrpGetEnterpriseIds'],
[
Fiddle::TYPE_VOIDP, # tokenHandle : HANDLE
Fiddle::TYPE_VOIDP, # numberOfBytes : DWORD* optional, in/out
Fiddle::TYPE_VOIDP, # enterpriseIds : LPCWSTR* optional, out
Fiddle::TYPE_VOIDP, # enterpriseIdCount : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "srpapi")]
extern "system" {
fn SrpGetEnterpriseIds(
tokenHandle: *mut core::ffi::c_void, // HANDLE
numberOfBytes: *mut u32, // DWORD* optional, in/out
enterpriseIds: *const *const u16, // LPCWSTR* optional, out
enterpriseIdCount: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("srpapi.dll")]
public static extern int SrpGetEnterpriseIds(IntPtr tokenHandle, IntPtr numberOfBytes, IntPtr enterpriseIds, out uint enterpriseIdCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'srpapi_SrpGetEnterpriseIds' -Namespace Win32 -PassThru
# $api::SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)#uselib "srpapi.dll"
#func global SrpGetEnterpriseIds "SrpGetEnterpriseIds" sptr, sptr, sptr, sptr
; SrpGetEnterpriseIds tokenHandle, varptr(numberOfBytes), varptr(enterpriseIds), varptr(enterpriseIdCount) ; 戻り値は stat
; tokenHandle : HANDLE -> "sptr"
; numberOfBytes : DWORD* optional, in/out -> "sptr"
; enterpriseIds : LPCWSTR* optional, out -> "sptr"
; enterpriseIdCount : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "srpapi.dll" #cfunc global SrpGetEnterpriseIds "SrpGetEnterpriseIds" sptr, var, var, var ; res = SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount) ; tokenHandle : HANDLE -> "sptr" ; numberOfBytes : DWORD* optional, in/out -> "var" ; enterpriseIds : LPCWSTR* optional, out -> "var" ; enterpriseIdCount : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "srpapi.dll" #cfunc global SrpGetEnterpriseIds "SrpGetEnterpriseIds" sptr, sptr, sptr, sptr ; res = SrpGetEnterpriseIds(tokenHandle, varptr(numberOfBytes), varptr(enterpriseIds), varptr(enterpriseIdCount)) ; tokenHandle : HANDLE -> "sptr" ; numberOfBytes : DWORD* optional, in/out -> "sptr" ; enterpriseIds : LPCWSTR* optional, out -> "sptr" ; enterpriseIdCount : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SrpGetEnterpriseIds(HANDLE tokenHandle, DWORD* numberOfBytes, LPCWSTR* enterpriseIds, DWORD* enterpriseIdCount) #uselib "srpapi.dll" #cfunc global SrpGetEnterpriseIds "SrpGetEnterpriseIds" intptr, var, var, var ; res = SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount) ; tokenHandle : HANDLE -> "intptr" ; numberOfBytes : DWORD* optional, in/out -> "var" ; enterpriseIds : LPCWSTR* optional, out -> "var" ; enterpriseIdCount : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SrpGetEnterpriseIds(HANDLE tokenHandle, DWORD* numberOfBytes, LPCWSTR* enterpriseIds, DWORD* enterpriseIdCount) #uselib "srpapi.dll" #cfunc global SrpGetEnterpriseIds "SrpGetEnterpriseIds" intptr, intptr, intptr, intptr ; res = SrpGetEnterpriseIds(tokenHandle, varptr(numberOfBytes), varptr(enterpriseIds), varptr(enterpriseIdCount)) ; tokenHandle : HANDLE -> "intptr" ; numberOfBytes : DWORD* optional, in/out -> "intptr" ; enterpriseIds : LPCWSTR* optional, out -> "intptr" ; enterpriseIdCount : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
srpapi = windows.NewLazySystemDLL("srpapi.dll")
procSrpGetEnterpriseIds = srpapi.NewProc("SrpGetEnterpriseIds")
)
// tokenHandle (HANDLE), numberOfBytes (DWORD* optional, in/out), enterpriseIds (LPCWSTR* optional, out), enterpriseIdCount (DWORD* out)
r1, _, err := procSrpGetEnterpriseIds.Call(
uintptr(tokenHandle),
uintptr(numberOfBytes),
uintptr(enterpriseIds),
uintptr(enterpriseIdCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SrpGetEnterpriseIds(
tokenHandle: THandle; // HANDLE
numberOfBytes: Pointer; // DWORD* optional, in/out
enterpriseIds: PPWideChar; // LPCWSTR* optional, out
enterpriseIdCount: Pointer // DWORD* out
): Integer; stdcall;
external 'srpapi.dll' name 'SrpGetEnterpriseIds';result := DllCall("srpapi\SrpGetEnterpriseIds"
, "Ptr", tokenHandle ; HANDLE
, "Ptr", numberOfBytes ; DWORD* optional, in/out
, "Ptr", enterpriseIds ; LPCWSTR* optional, out
, "Ptr", enterpriseIdCount ; DWORD* out
, "Int") ; return: HRESULT●SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount) = DLL("srpapi.dll", "int SrpGetEnterpriseIds(void*, void*, void*, void*)")
# 呼び出し: SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)
# tokenHandle : HANDLE -> "void*"
# numberOfBytes : DWORD* optional, in/out -> "void*"
# enterpriseIds : LPCWSTR* optional, out -> "void*"
# enterpriseIdCount : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "srpapi" fn SrpGetEnterpriseIds(
tokenHandle: ?*anyopaque, // HANDLE
numberOfBytes: [*c]u32, // DWORD* optional, in/out
enterpriseIds: [*c][*c]u16, // LPCWSTR* optional, out
enterpriseIdCount: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc SrpGetEnterpriseIds(
tokenHandle: pointer, # HANDLE
numberOfBytes: ptr uint32, # DWORD* optional, in/out
enterpriseIds: ptr WideCString, # LPCWSTR* optional, out
enterpriseIdCount: ptr uint32 # DWORD* out
): int32 {.importc: "SrpGetEnterpriseIds", stdcall, dynlib: "srpapi.dll".}pragma(lib, "srpapi");
extern(Windows)
int SrpGetEnterpriseIds(
void* tokenHandle, // HANDLE
uint* numberOfBytes, // DWORD* optional, in/out
wchar** enterpriseIds, // LPCWSTR* optional, out
uint* enterpriseIdCount // DWORD* out
);ccall((:SrpGetEnterpriseIds, "srpapi.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{UInt32}, Ptr{Ptr{UInt16}}, Ptr{UInt32}),
tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)
# tokenHandle : HANDLE -> Ptr{Cvoid}
# numberOfBytes : DWORD* optional, in/out -> Ptr{UInt32}
# enterpriseIds : LPCWSTR* optional, out -> Ptr{Ptr{UInt16}}
# enterpriseIdCount : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SrpGetEnterpriseIds(
void* tokenHandle,
uint32_t* numberOfBytes,
uint16_t** enterpriseIds,
uint32_t* enterpriseIdCount);
]]
local srpapi = ffi.load("srpapi")
-- srpapi.SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)
-- tokenHandle : HANDLE
-- numberOfBytes : DWORD* optional, in/out
-- enterpriseIds : LPCWSTR* optional, out
-- enterpriseIdCount : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('srpapi.dll');
const SrpGetEnterpriseIds = lib.func('__stdcall', 'SrpGetEnterpriseIds', 'int32_t', ['void *', 'uint32_t *', 'void *', 'uint32_t *']);
// SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)
// tokenHandle : HANDLE -> 'void *'
// numberOfBytes : DWORD* optional, in/out -> 'uint32_t *'
// enterpriseIds : LPCWSTR* optional, out -> 'void *'
// enterpriseIdCount : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("srpapi.dll", {
SrpGetEnterpriseIds: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount)
// tokenHandle : HANDLE -> "pointer"
// numberOfBytes : DWORD* optional, in/out -> "pointer"
// enterpriseIds : LPCWSTR* optional, out -> "pointer"
// enterpriseIdCount : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SrpGetEnterpriseIds(
void* tokenHandle,
uint32_t* numberOfBytes,
uint16_t** enterpriseIds,
uint32_t* enterpriseIdCount);
C, "srpapi.dll");
// $ffi->SrpGetEnterpriseIds(tokenHandle, numberOfBytes, enterpriseIds, enterpriseIdCount);
// tokenHandle : HANDLE
// numberOfBytes : DWORD* optional, in/out
// enterpriseIds : LPCWSTR* optional, out
// enterpriseIdCount : 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 Srpapi extends StdCallLibrary {
Srpapi INSTANCE = Native.load("srpapi", Srpapi.class);
int SrpGetEnterpriseIds(
Pointer tokenHandle, // HANDLE
IntByReference numberOfBytes, // DWORD* optional, in/out
PointerByReference enterpriseIds, // LPCWSTR* optional, out
IntByReference enterpriseIdCount // DWORD* out
);
}@[Link("srpapi")]
lib Libsrpapi
fun SrpGetEnterpriseIds = SrpGetEnterpriseIds(
tokenHandle : Void*, # HANDLE
numberOfBytes : UInt32*, # DWORD* optional, in/out
enterpriseIds : UInt16**, # LPCWSTR* optional, out
enterpriseIdCount : 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 SrpGetEnterpriseIdsNative = Int32 Function(Pointer<Void>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
typedef SrpGetEnterpriseIdsDart = int Function(Pointer<Void>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
final SrpGetEnterpriseIds = DynamicLibrary.open('srpapi.dll')
.lookupFunction<SrpGetEnterpriseIdsNative, SrpGetEnterpriseIdsDart>('SrpGetEnterpriseIds');
// tokenHandle : HANDLE -> Pointer<Void>
// numberOfBytes : DWORD* optional, in/out -> Pointer<Uint32>
// enterpriseIds : LPCWSTR* optional, out -> Pointer<Pointer<Utf16>>
// enterpriseIdCount : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SrpGetEnterpriseIds(
tokenHandle: THandle; // HANDLE
numberOfBytes: Pointer; // DWORD* optional, in/out
enterpriseIds: PPWideChar; // LPCWSTR* optional, out
enterpriseIdCount: Pointer // DWORD* out
): Integer; stdcall;
external 'srpapi.dll' name 'SrpGetEnterpriseIds';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SrpGetEnterpriseIds"
c_SrpGetEnterpriseIds :: Ptr () -> Ptr Word32 -> Ptr CWString -> Ptr Word32 -> IO Int32
-- tokenHandle : HANDLE -> Ptr ()
-- numberOfBytes : DWORD* optional, in/out -> Ptr Word32
-- enterpriseIds : LPCWSTR* optional, out -> Ptr CWString
-- enterpriseIdCount : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let srpgetenterpriseids =
foreign "SrpGetEnterpriseIds"
((ptr void) @-> (ptr uint32_t) @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> returning int32_t)
(* tokenHandle : HANDLE -> (ptr void) *)
(* numberOfBytes : DWORD* optional, in/out -> (ptr uint32_t) *)
(* enterpriseIds : LPCWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* enterpriseIdCount : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library srpapi (t "srpapi.dll"))
(cffi:use-foreign-library srpapi)
(cffi:defcfun ("SrpGetEnterpriseIds" srp-get-enterprise-ids :convention :stdcall) :int32
(token-handle :pointer) ; HANDLE
(number-of-bytes :pointer) ; DWORD* optional, in/out
(enterprise-ids :pointer) ; LPCWSTR* optional, out
(enterprise-id-count :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SrpGetEnterpriseIds = Win32::API::More->new('srpapi',
'int SrpGetEnterpriseIds(HANDLE tokenHandle, LPVOID numberOfBytes, LPVOID enterpriseIds, LPVOID enterpriseIdCount)');
# my $ret = $SrpGetEnterpriseIds->Call($tokenHandle, $numberOfBytes, $enterpriseIds, $enterpriseIdCount);
# tokenHandle : HANDLE -> HANDLE
# numberOfBytes : DWORD* optional, in/out -> LPVOID
# enterpriseIds : LPCWSTR* optional, out -> LPVOID
# enterpriseIdCount : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。