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

WldpCanExecuteStream

関数
ストリームの内容が実行許可されるかを評価する。
DLLWldp.dll呼出規約winapi

シグネチャ

// Wldp.dll
#include <windows.h>

HRESULT WldpCanExecuteStream(
    const GUID* host,
    WLDP_EXECUTION_EVALUATION_OPTIONS options,
    IStream* stream,
    LPCWSTR auditInfo,   // optional
    WLDP_EXECUTION_POLICY* result
);

パラメーター

名前方向説明
hostGUID*in呼び出し元ホストを識別するGUIDへのポインタ。
optionsWLDP_EXECUTION_EVALUATION_OPTIONSin評価動作を制御するWLDP_EXECUTION_EVALUATION_OPTIONSフラグ。
streamIStream*in実行可否を評価する対象データを供給するIStreamインターフェイス。
auditInfoLPCWSTRinoptional監査ログに記録する付加情報の文字列(Unicode)。NULL可。
resultWLDP_EXECUTION_POLICY*out出力として実行可否ポリシー(WLDP_EXECUTION_POLICY)を受け取るポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

// Wldp.dll
#include <windows.h>

HRESULT WldpCanExecuteStream(
    const GUID* host,
    WLDP_EXECUTION_EVALUATION_OPTIONS options,
    IStream* stream,
    LPCWSTR auditInfo,   // optional
    WLDP_EXECUTION_POLICY* result
);
[DllImport("Wldp.dll", ExactSpelling = true)]
static extern int WldpCanExecuteStream(
    ref Guid host,   // GUID*
    int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
    IntPtr stream,   // IStream*
    [MarshalAs(UnmanagedType.LPWStr)] string auditInfo,   // LPCWSTR optional
    out int result   // WLDP_EXECUTION_POLICY* out
);
<DllImport("Wldp.dll", ExactSpelling:=True)>
Public Shared Function WldpCanExecuteStream(
    ByRef host As Guid,   ' GUID*
    options As Integer,   ' WLDP_EXECUTION_EVALUATION_OPTIONS
    stream As IntPtr,   ' IStream*
    <MarshalAs(UnmanagedType.LPWStr)> auditInfo As String,   ' LPCWSTR optional
    <Out> ByRef result As Integer   ' WLDP_EXECUTION_POLICY* out
) As Integer
End Function
' host : GUID*
' options : WLDP_EXECUTION_EVALUATION_OPTIONS
' stream : IStream*
' auditInfo : LPCWSTR optional
' result : WLDP_EXECUTION_POLICY* out
Declare PtrSafe Function WldpCanExecuteStream Lib "wldp" ( _
    ByVal host As LongPtr, _
    ByVal options As Long, _
    ByVal stream As LongPtr, _
    ByVal auditInfo As LongPtr, _
    ByRef result As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WldpCanExecuteStream = ctypes.windll.wldp.WldpCanExecuteStream
WldpCanExecuteStream.restype = ctypes.c_int
WldpCanExecuteStream.argtypes = [
    ctypes.c_void_p,  # host : GUID*
    ctypes.c_int,  # options : WLDP_EXECUTION_EVALUATION_OPTIONS
    ctypes.c_void_p,  # stream : IStream*
    wintypes.LPCWSTR,  # auditInfo : LPCWSTR optional
    ctypes.c_void_p,  # result : WLDP_EXECUTION_POLICY* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Wldp.dll')
WldpCanExecuteStream = Fiddle::Function.new(
  lib['WldpCanExecuteStream'],
  [
    Fiddle::TYPE_VOIDP,  # host : GUID*
    Fiddle::TYPE_INT,  # options : WLDP_EXECUTION_EVALUATION_OPTIONS
    Fiddle::TYPE_VOIDP,  # stream : IStream*
    Fiddle::TYPE_VOIDP,  # auditInfo : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # result : WLDP_EXECUTION_POLICY* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wldp")]
extern "system" {
    fn WldpCanExecuteStream(
        host: *const GUID,  // GUID*
        options: i32,  // WLDP_EXECUTION_EVALUATION_OPTIONS
        stream: *mut core::ffi::c_void,  // IStream*
        auditInfo: *const u16,  // LPCWSTR optional
        result: *mut i32  // WLDP_EXECUTION_POLICY* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("Wldp.dll")]
public static extern int WldpCanExecuteStream(ref Guid host, int options, IntPtr stream, [MarshalAs(UnmanagedType.LPWStr)] string auditInfo, out int result);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Wldp_WldpCanExecuteStream' -Namespace Win32 -PassThru
# $api::WldpCanExecuteStream(host, options, stream, auditInfo, result)
#uselib "Wldp.dll"
#func global WldpCanExecuteStream "WldpCanExecuteStream" sptr, sptr, sptr, sptr, sptr
; WldpCanExecuteStream varptr(host), options, stream, auditInfo, varptr(result)   ; 戻り値は stat
; host : GUID* -> "sptr"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "sptr"
; stream : IStream* -> "sptr"
; auditInfo : LPCWSTR optional -> "sptr"
; result : WLDP_EXECUTION_POLICY* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "Wldp.dll"
#cfunc global WldpCanExecuteStream "WldpCanExecuteStream" var, int, sptr, wstr, var
; res = WldpCanExecuteStream(host, options, stream, auditInfo, result)
; host : GUID* -> "var"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
; stream : IStream* -> "sptr"
; auditInfo : LPCWSTR optional -> "wstr"
; result : WLDP_EXECUTION_POLICY* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WldpCanExecuteStream(GUID* host, WLDP_EXECUTION_EVALUATION_OPTIONS options, IStream* stream, LPCWSTR auditInfo, WLDP_EXECUTION_POLICY* result)
#uselib "Wldp.dll"
#cfunc global WldpCanExecuteStream "WldpCanExecuteStream" var, int, intptr, wstr, var
; res = WldpCanExecuteStream(host, options, stream, auditInfo, result)
; host : GUID* -> "var"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
; stream : IStream* -> "intptr"
; auditInfo : LPCWSTR optional -> "wstr"
; result : WLDP_EXECUTION_POLICY* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldp = windows.NewLazySystemDLL("Wldp.dll")
	procWldpCanExecuteStream = wldp.NewProc("WldpCanExecuteStream")
)

// host (GUID*), options (WLDP_EXECUTION_EVALUATION_OPTIONS), stream (IStream*), auditInfo (LPCWSTR optional), result (WLDP_EXECUTION_POLICY* out)
r1, _, err := procWldpCanExecuteStream.Call(
	uintptr(host),
	uintptr(options),
	uintptr(stream),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(auditInfo))),
	uintptr(result),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WldpCanExecuteStream(
  host: PGUID;   // GUID*
  options: Integer;   // WLDP_EXECUTION_EVALUATION_OPTIONS
  stream: Pointer;   // IStream*
  auditInfo: PWideChar;   // LPCWSTR optional
  result: Pointer   // WLDP_EXECUTION_POLICY* out
): Integer; stdcall;
  external 'Wldp.dll' name 'WldpCanExecuteStream';
result := DllCall("Wldp\WldpCanExecuteStream"
    , "Ptr", host   ; GUID*
    , "Int", options   ; WLDP_EXECUTION_EVALUATION_OPTIONS
    , "Ptr", stream   ; IStream*
    , "WStr", auditInfo   ; LPCWSTR optional
    , "Ptr", result   ; WLDP_EXECUTION_POLICY* out
    , "Int")   ; return: HRESULT
●WldpCanExecuteStream(host, options, stream, auditInfo, result) = DLL("Wldp.dll", "int WldpCanExecuteStream(void*, int, void*, char*, void*)")
# 呼び出し: WldpCanExecuteStream(host, options, stream, auditInfo, result)
# host : GUID* -> "void*"
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
# stream : IStream* -> "void*"
# auditInfo : LPCWSTR optional -> "char*"
# result : WLDP_EXECUTION_POLICY* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wldp" fn WldpCanExecuteStream(
    host: [*c]GUID, // GUID*
    options: i32, // WLDP_EXECUTION_EVALUATION_OPTIONS
    stream: ?*anyopaque, // IStream*
    auditInfo: [*c]const u16, // LPCWSTR optional
    result: [*c]i32 // WLDP_EXECUTION_POLICY* out
) callconv(std.os.windows.WINAPI) i32;
proc WldpCanExecuteStream(
    host: ptr GUID,  # GUID*
    options: int32,  # WLDP_EXECUTION_EVALUATION_OPTIONS
    stream: pointer,  # IStream*
    auditInfo: WideCString,  # LPCWSTR optional
    result: ptr int32  # WLDP_EXECUTION_POLICY* out
): int32 {.importc: "WldpCanExecuteStream", stdcall, dynlib: "Wldp.dll".}
pragma(lib, "wldp");
extern(Windows)
int WldpCanExecuteStream(
    GUID* host,   // GUID*
    int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
    void* stream,   // IStream*
    const(wchar)* auditInfo,   // LPCWSTR optional
    int* result   // WLDP_EXECUTION_POLICY* out
);
ccall((:WldpCanExecuteStream, "Wldp.dll"), stdcall, Int32,
      (Ptr{GUID}, Int32, Ptr{Cvoid}, Cwstring, Ptr{Int32}),
      host, options, stream, auditInfo, result)
# host : GUID* -> Ptr{GUID}
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
# stream : IStream* -> Ptr{Cvoid}
# auditInfo : LPCWSTR optional -> Cwstring
# result : WLDP_EXECUTION_POLICY* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WldpCanExecuteStream(
    void* host,
    int32_t options,
    void* stream,
    const uint16_t* auditInfo,
    int32_t* result);
]]
local wldp = ffi.load("wldp")
-- wldp.WldpCanExecuteStream(host, options, stream, auditInfo, result)
-- host : GUID*
-- options : WLDP_EXECUTION_EVALUATION_OPTIONS
-- stream : IStream*
-- auditInfo : LPCWSTR optional
-- result : WLDP_EXECUTION_POLICY* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('Wldp.dll');
const WldpCanExecuteStream = lib.func('__stdcall', 'WldpCanExecuteStream', 'int32_t', ['void *', 'int32_t', 'void *', 'str16', 'int32_t *']);
// WldpCanExecuteStream(host, options, stream, auditInfo, result)
// host : GUID* -> 'void *'
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> 'int32_t'
// stream : IStream* -> 'void *'
// auditInfo : LPCWSTR optional -> 'str16'
// result : WLDP_EXECUTION_POLICY* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("Wldp.dll", {
  WldpCanExecuteStream: { parameters: ["pointer", "i32", "pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.WldpCanExecuteStream(host, options, stream, auditInfo, result)
// host : GUID* -> "pointer"
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "i32"
// stream : IStream* -> "pointer"
// auditInfo : LPCWSTR optional -> "buffer"
// result : WLDP_EXECUTION_POLICY* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WldpCanExecuteStream(
    void* host,
    int32_t options,
    void* stream,
    const uint16_t* auditInfo,
    int32_t* result);
C, "Wldp.dll");
// $ffi->WldpCanExecuteStream(host, options, stream, auditInfo, result);
// host : GUID*
// options : WLDP_EXECUTION_EVALUATION_OPTIONS
// stream : IStream*
// auditInfo : LPCWSTR optional
// result : WLDP_EXECUTION_POLICY* 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 Wldp extends StdCallLibrary {
    Wldp INSTANCE = Native.load("wldp", Wldp.class);
    int WldpCanExecuteStream(
        Pointer host,   // GUID*
        int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
        Pointer stream,   // IStream*
        WString auditInfo,   // LPCWSTR optional
        IntByReference result   // WLDP_EXECUTION_POLICY* out
    );
}
@[Link("wldp")]
lib LibWldp
  fun WldpCanExecuteStream = WldpCanExecuteStream(
    host : GUID*,   # GUID*
    options : Int32,   # WLDP_EXECUTION_EVALUATION_OPTIONS
    stream : Void*,   # IStream*
    auditInfo : UInt16*,   # LPCWSTR optional
    result : Int32*   # WLDP_EXECUTION_POLICY* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WldpCanExecuteStreamNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Pointer<Utf16>, Pointer<Int32>);
typedef WldpCanExecuteStreamDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Utf16>, Pointer<Int32>);
final WldpCanExecuteStream = DynamicLibrary.open('Wldp.dll')
    .lookupFunction<WldpCanExecuteStreamNative, WldpCanExecuteStreamDart>('WldpCanExecuteStream');
// host : GUID* -> Pointer<Void>
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
// stream : IStream* -> Pointer<Void>
// auditInfo : LPCWSTR optional -> Pointer<Utf16>
// result : WLDP_EXECUTION_POLICY* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WldpCanExecuteStream(
  host: PGUID;   // GUID*
  options: Integer;   // WLDP_EXECUTION_EVALUATION_OPTIONS
  stream: Pointer;   // IStream*
  auditInfo: PWideChar;   // LPCWSTR optional
  result: Pointer   // WLDP_EXECUTION_POLICY* out
): Integer; stdcall;
  external 'Wldp.dll' name 'WldpCanExecuteStream';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WldpCanExecuteStream"
  c_WldpCanExecuteStream :: Ptr () -> Int32 -> Ptr () -> CWString -> Ptr Int32 -> IO Int32
-- host : GUID* -> Ptr ()
-- options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
-- stream : IStream* -> Ptr ()
-- auditInfo : LPCWSTR optional -> CWString
-- result : WLDP_EXECUTION_POLICY* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wldpcanexecutestream =
  foreign "WldpCanExecuteStream"
    ((ptr void) @-> int32_t @-> (ptr void) @-> (ptr uint16_t) @-> (ptr int32_t) @-> returning int32_t)
(* host : GUID* -> (ptr void) *)
(* options : WLDP_EXECUTION_EVALUATION_OPTIONS -> int32_t *)
(* stream : IStream* -> (ptr void) *)
(* auditInfo : LPCWSTR optional -> (ptr uint16_t) *)
(* result : WLDP_EXECUTION_POLICY* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wldp (t "Wldp.dll"))
(cffi:use-foreign-library wldp)

(cffi:defcfun ("WldpCanExecuteStream" wldp-can-execute-stream :convention :stdcall) :int32
  (host :pointer)   ; GUID*
  (options :int32)   ; WLDP_EXECUTION_EVALUATION_OPTIONS
  (stream :pointer)   ; IStream*
  (audit-info (:string :encoding :utf-16le))   ; LPCWSTR optional
  (result :pointer))   ; WLDP_EXECUTION_POLICY* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WldpCanExecuteStream = Win32::API::More->new('Wldp',
    'int WldpCanExecuteStream(LPVOID host, int options, LPVOID stream, LPCWSTR auditInfo, LPVOID result)');
# my $ret = $WldpCanExecuteStream->Call($host, $options, $stream, $auditInfo, $result);
# host : GUID* -> LPVOID
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> int
# stream : IStream* -> LPVOID
# auditInfo : LPCWSTR optional -> LPCWSTR
# result : WLDP_EXECUTION_POLICY* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型