ホーム › System.WinRT › CreateRandomAccessStreamOverStream
CreateRandomAccessStreamOverStream
関数IStream上にWinRTランダムアクセスストリームを作成する。
シグネチャ
// api-ms-win-shcore-stream-winrt-l1-1-0.dll
#include <windows.h>
HRESULT CreateRandomAccessStreamOverStream(
IStream* stream,
BSOS_OPTIONS options,
const GUID* riid,
void** ppv
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| stream | IStream* | in | ラップ対象となる既存のIStreamインターフェイス。 |
| options | BSOS_OPTIONS | in | ストリーム動作を制御するBSOS_OPTIONS列挙値。 |
| riid | GUID* | in | 要求するインターフェイスのIID(通常IRandomAccessStream)へのポインタ。 |
| ppv | void** | out | 出力として生成されたストリームインターフェイスを受け取るポインタのアドレス。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-shcore-stream-winrt-l1-1-0.dll
#include <windows.h>
HRESULT CreateRandomAccessStreamOverStream(
IStream* stream,
BSOS_OPTIONS options,
const GUID* riid,
void** ppv
);[DllImport("api-ms-win-shcore-stream-winrt-l1-1-0.dll", ExactSpelling = true)]
static extern int CreateRandomAccessStreamOverStream(
IntPtr stream, // IStream*
int options, // BSOS_OPTIONS
ref Guid riid, // GUID*
IntPtr ppv // void** out
);<DllImport("api-ms-win-shcore-stream-winrt-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function CreateRandomAccessStreamOverStream(
stream As IntPtr, ' IStream*
options As Integer, ' BSOS_OPTIONS
ByRef riid As Guid, ' GUID*
ppv As IntPtr ' void** out
) As Integer
End Function' stream : IStream*
' options : BSOS_OPTIONS
' riid : GUID*
' ppv : void** out
Declare PtrSafe Function CreateRandomAccessStreamOverStream Lib "api-ms-win-shcore-stream-winrt-l1-1-0" ( _
ByVal stream As LongPtr, _
ByVal options As Long, _
ByVal riid As LongPtr, _
ByVal ppv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateRandomAccessStreamOverStream = ctypes.windll.LoadLibrary("api-ms-win-shcore-stream-winrt-l1-1-0.dll").CreateRandomAccessStreamOverStream
CreateRandomAccessStreamOverStream.restype = ctypes.c_int
CreateRandomAccessStreamOverStream.argtypes = [
ctypes.c_void_p, # stream : IStream*
ctypes.c_int, # options : BSOS_OPTIONS
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # ppv : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-shcore-stream-winrt-l1-1-0.dll')
CreateRandomAccessStreamOverStream = Fiddle::Function.new(
lib['CreateRandomAccessStreamOverStream'],
[
Fiddle::TYPE_VOIDP, # stream : IStream*
Fiddle::TYPE_INT, # options : BSOS_OPTIONS
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # ppv : void** out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-shcore-stream-winrt-l1-1-0")]
extern "system" {
fn CreateRandomAccessStreamOverStream(
stream: *mut core::ffi::c_void, // IStream*
options: i32, // BSOS_OPTIONS
riid: *const GUID, // GUID*
ppv: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-shcore-stream-winrt-l1-1-0.dll")]
public static extern int CreateRandomAccessStreamOverStream(IntPtr stream, int options, ref Guid riid, IntPtr ppv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-shcore-stream-winrt-l1-1-0_CreateRandomAccessStreamOverStream' -Namespace Win32 -PassThru
# $api::CreateRandomAccessStreamOverStream(stream, options, riid, ppv)#uselib "api-ms-win-shcore-stream-winrt-l1-1-0.dll"
#func global CreateRandomAccessStreamOverStream "CreateRandomAccessStreamOverStream" sptr, sptr, sptr, sptr
; CreateRandomAccessStreamOverStream stream, options, varptr(riid), ppv ; 戻り値は stat
; stream : IStream* -> "sptr"
; options : BSOS_OPTIONS -> "sptr"
; riid : GUID* -> "sptr"
; ppv : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-shcore-stream-winrt-l1-1-0.dll" #cfunc global CreateRandomAccessStreamOverStream "CreateRandomAccessStreamOverStream" sptr, int, var, sptr ; res = CreateRandomAccessStreamOverStream(stream, options, riid, ppv) ; stream : IStream* -> "sptr" ; options : BSOS_OPTIONS -> "int" ; riid : GUID* -> "var" ; ppv : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-shcore-stream-winrt-l1-1-0.dll" #cfunc global CreateRandomAccessStreamOverStream "CreateRandomAccessStreamOverStream" sptr, int, sptr, sptr ; res = CreateRandomAccessStreamOverStream(stream, options, varptr(riid), ppv) ; stream : IStream* -> "sptr" ; options : BSOS_OPTIONS -> "int" ; riid : GUID* -> "sptr" ; ppv : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CreateRandomAccessStreamOverStream(IStream* stream, BSOS_OPTIONS options, GUID* riid, void** ppv) #uselib "api-ms-win-shcore-stream-winrt-l1-1-0.dll" #cfunc global CreateRandomAccessStreamOverStream "CreateRandomAccessStreamOverStream" intptr, int, var, intptr ; res = CreateRandomAccessStreamOverStream(stream, options, riid, ppv) ; stream : IStream* -> "intptr" ; options : BSOS_OPTIONS -> "int" ; riid : GUID* -> "var" ; ppv : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CreateRandomAccessStreamOverStream(IStream* stream, BSOS_OPTIONS options, GUID* riid, void** ppv) #uselib "api-ms-win-shcore-stream-winrt-l1-1-0.dll" #cfunc global CreateRandomAccessStreamOverStream "CreateRandomAccessStreamOverStream" intptr, int, intptr, intptr ; res = CreateRandomAccessStreamOverStream(stream, options, varptr(riid), ppv) ; stream : IStream* -> "intptr" ; options : BSOS_OPTIONS -> "int" ; riid : GUID* -> "intptr" ; ppv : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_shcore_stream_winrt_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-shcore-stream-winrt-l1-1-0.dll")
procCreateRandomAccessStreamOverStream = api_ms_win_shcore_stream_winrt_l1_1_0.NewProc("CreateRandomAccessStreamOverStream")
)
// stream (IStream*), options (BSOS_OPTIONS), riid (GUID*), ppv (void** out)
r1, _, err := procCreateRandomAccessStreamOverStream.Call(
uintptr(stream),
uintptr(options),
uintptr(riid),
uintptr(ppv),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CreateRandomAccessStreamOverStream(
stream: Pointer; // IStream*
options: Integer; // BSOS_OPTIONS
riid: PGUID; // GUID*
ppv: Pointer // void** out
): Integer; stdcall;
external 'api-ms-win-shcore-stream-winrt-l1-1-0.dll' name 'CreateRandomAccessStreamOverStream';result := DllCall("api-ms-win-shcore-stream-winrt-l1-1-0\CreateRandomAccessStreamOverStream"
, "Ptr", stream ; IStream*
, "Int", options ; BSOS_OPTIONS
, "Ptr", riid ; GUID*
, "Ptr", ppv ; void** out
, "Int") ; return: HRESULT●CreateRandomAccessStreamOverStream(stream, options, riid, ppv) = DLL("api-ms-win-shcore-stream-winrt-l1-1-0.dll", "int CreateRandomAccessStreamOverStream(void*, int, void*, void*)")
# 呼び出し: CreateRandomAccessStreamOverStream(stream, options, riid, ppv)
# stream : IStream* -> "void*"
# options : BSOS_OPTIONS -> "int"
# riid : GUID* -> "void*"
# ppv : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-shcore-stream-winrt-l1-1-0" fn CreateRandomAccessStreamOverStream(
stream: ?*anyopaque, // IStream*
options: i32, // BSOS_OPTIONS
riid: [*c]GUID, // GUID*
ppv: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc CreateRandomAccessStreamOverStream(
stream: pointer, # IStream*
options: int32, # BSOS_OPTIONS
riid: ptr GUID, # GUID*
ppv: pointer # void** out
): int32 {.importc: "CreateRandomAccessStreamOverStream", stdcall, dynlib: "api-ms-win-shcore-stream-winrt-l1-1-0.dll".}pragma(lib, "api-ms-win-shcore-stream-winrt-l1-1-0");
extern(Windows)
int CreateRandomAccessStreamOverStream(
void* stream, // IStream*
int options, // BSOS_OPTIONS
GUID* riid, // GUID*
void** ppv // void** out
);ccall((:CreateRandomAccessStreamOverStream, "api-ms-win-shcore-stream-winrt-l1-1-0.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Ptr{GUID}, Ptr{Cvoid}),
stream, options, riid, ppv)
# stream : IStream* -> Ptr{Cvoid}
# options : BSOS_OPTIONS -> Int32
# riid : GUID* -> Ptr{GUID}
# ppv : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CreateRandomAccessStreamOverStream(
void* stream,
int32_t options,
void* riid,
void** ppv);
]]
local api-ms-win-shcore-stream-winrt-l1-1-0 = ffi.load("api-ms-win-shcore-stream-winrt-l1-1-0")
-- api-ms-win-shcore-stream-winrt-l1-1-0.CreateRandomAccessStreamOverStream(stream, options, riid, ppv)
-- stream : IStream*
-- options : BSOS_OPTIONS
-- riid : GUID*
-- ppv : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-shcore-stream-winrt-l1-1-0.dll');
const CreateRandomAccessStreamOverStream = lib.func('__stdcall', 'CreateRandomAccessStreamOverStream', 'int32_t', ['void *', 'int32_t', 'void *', 'void *']);
// CreateRandomAccessStreamOverStream(stream, options, riid, ppv)
// stream : IStream* -> 'void *'
// options : BSOS_OPTIONS -> 'int32_t'
// riid : GUID* -> 'void *'
// ppv : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-shcore-stream-winrt-l1-1-0.dll", {
CreateRandomAccessStreamOverStream: { parameters: ["pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CreateRandomAccessStreamOverStream(stream, options, riid, ppv)
// stream : IStream* -> "pointer"
// options : BSOS_OPTIONS -> "i32"
// riid : GUID* -> "pointer"
// ppv : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CreateRandomAccessStreamOverStream(
void* stream,
int32_t options,
void* riid,
void** ppv);
C, "api-ms-win-shcore-stream-winrt-l1-1-0.dll");
// $ffi->CreateRandomAccessStreamOverStream(stream, options, riid, ppv);
// stream : IStream*
// options : BSOS_OPTIONS
// riid : GUID*
// ppv : void** 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 Api-ms-win-shcore-stream-winrt-l1-1-0 extends StdCallLibrary {
Api-ms-win-shcore-stream-winrt-l1-1-0 INSTANCE = Native.load("api-ms-win-shcore-stream-winrt-l1-1-0", Api-ms-win-shcore-stream-winrt-l1-1-0.class);
int CreateRandomAccessStreamOverStream(
Pointer stream, // IStream*
int options, // BSOS_OPTIONS
Pointer riid, // GUID*
Pointer ppv // void** out
);
}@[Link("api-ms-win-shcore-stream-winrt-l1-1-0")]
lib Libapi-ms-win-shcore-stream-winrt-l1-1-0
fun CreateRandomAccessStreamOverStream = CreateRandomAccessStreamOverStream(
stream : Void*, # IStream*
options : Int32, # BSOS_OPTIONS
riid : GUID*, # GUID*
ppv : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateRandomAccessStreamOverStreamNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Pointer<Void>);
typedef CreateRandomAccessStreamOverStreamDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Void>);
final CreateRandomAccessStreamOverStream = DynamicLibrary.open('api-ms-win-shcore-stream-winrt-l1-1-0.dll')
.lookupFunction<CreateRandomAccessStreamOverStreamNative, CreateRandomAccessStreamOverStreamDart>('CreateRandomAccessStreamOverStream');
// stream : IStream* -> Pointer<Void>
// options : BSOS_OPTIONS -> Int32
// riid : GUID* -> Pointer<Void>
// ppv : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateRandomAccessStreamOverStream(
stream: Pointer; // IStream*
options: Integer; // BSOS_OPTIONS
riid: PGUID; // GUID*
ppv: Pointer // void** out
): Integer; stdcall;
external 'api-ms-win-shcore-stream-winrt-l1-1-0.dll' name 'CreateRandomAccessStreamOverStream';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateRandomAccessStreamOverStream"
c_CreateRandomAccessStreamOverStream :: Ptr () -> Int32 -> Ptr () -> Ptr () -> IO Int32
-- stream : IStream* -> Ptr ()
-- options : BSOS_OPTIONS -> Int32
-- riid : GUID* -> Ptr ()
-- ppv : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createrandomaccessstreamoverstream =
foreign "CreateRandomAccessStreamOverStream"
((ptr void) @-> int32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* stream : IStream* -> (ptr void) *)
(* options : BSOS_OPTIONS -> int32_t *)
(* riid : GUID* -> (ptr void) *)
(* ppv : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-shcore-stream-winrt-l1-1-0 (t "api-ms-win-shcore-stream-winrt-l1-1-0.dll"))
(cffi:use-foreign-library api-ms-win-shcore-stream-winrt-l1-1-0)
(cffi:defcfun ("CreateRandomAccessStreamOverStream" create-random-access-stream-over-stream :convention :stdcall) :int32
(stream :pointer) ; IStream*
(options :int32) ; BSOS_OPTIONS
(riid :pointer) ; GUID*
(ppv :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateRandomAccessStreamOverStream = Win32::API::More->new('api-ms-win-shcore-stream-winrt-l1-1-0',
'int CreateRandomAccessStreamOverStream(LPVOID stream, int options, LPVOID riid, LPVOID ppv)');
# my $ret = $CreateRandomAccessStreamOverStream->Call($stream, $options, $riid, $ppv);
# stream : IStream* -> LPVOID
# options : BSOS_OPTIONS -> int
# riid : GUID* -> LPVOID
# ppv : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。