Win32 API 日本語リファレンス
ホームDevices.AllJoyn › alljoyn_abouticon_setcontent

alljoyn_abouticon_setcontent

関数
AboutIconにMIMEタイプ付きのアイコン画像データを設定する。
DLLMSAJApi.dll呼出規約winapi

シグネチャ

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

QStatus alljoyn_abouticon_setcontent(
    alljoyn_abouticon icon,
    LPCSTR type,
    BYTE* data,
    UINT_PTR csize,
    BYTE ownsData
);

パラメーター

名前方向説明
iconalljoyn_abouticoninアイコン画像データを設定する対象のAboutアイコンハンドル。
typeLPCSTRin画像のMIMEタイプ文字列(例:"image/png")。
dataBYTE*inout設定する画像バイト列の先頭ポインタ。
csizeUINT_PTRin画像データのバイト数。
ownsDataBYTEinデータの所有権をアイコンに委譲するか。非0で内部管理し自動解放する。

戻り値の型: QStatus

各言語での呼び出し定義

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

QStatus alljoyn_abouticon_setcontent(
    alljoyn_abouticon icon,
    LPCSTR type,
    BYTE* data,
    UINT_PTR csize,
    BYTE ownsData
);
[DllImport("MSAJApi.dll", ExactSpelling = true)]
static extern int alljoyn_abouticon_setcontent(
    IntPtr icon,   // alljoyn_abouticon
    [MarshalAs(UnmanagedType.LPStr)] string type,   // LPCSTR
    IntPtr data,   // BYTE* in/out
    UIntPtr csize,   // UINT_PTR
    byte ownsData   // BYTE
);
<DllImport("MSAJApi.dll", ExactSpelling:=True)>
Public Shared Function alljoyn_abouticon_setcontent(
    icon As IntPtr,   ' alljoyn_abouticon
    <MarshalAs(UnmanagedType.LPStr)> type As String,   ' LPCSTR
    data As IntPtr,   ' BYTE* in/out
    csize As UIntPtr,   ' UINT_PTR
    ownsData As Byte   ' BYTE
) As Integer
End Function
' icon : alljoyn_abouticon
' type : LPCSTR
' data : BYTE* in/out
' csize : UINT_PTR
' ownsData : BYTE
Declare PtrSafe Function alljoyn_abouticon_setcontent Lib "msajapi" ( _
    ByVal icon As LongPtr, _
    ByVal type As String, _
    ByVal data As LongPtr, _
    ByVal csize As LongPtr, _
    ByVal ownsData As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

alljoyn_abouticon_setcontent = ctypes.windll.msajapi.alljoyn_abouticon_setcontent
alljoyn_abouticon_setcontent.restype = ctypes.c_int
alljoyn_abouticon_setcontent.argtypes = [
    ctypes.c_ssize_t,  # icon : alljoyn_abouticon
    wintypes.LPCSTR,  # type : LPCSTR
    ctypes.POINTER(ctypes.c_ubyte),  # data : BYTE* in/out
    ctypes.c_size_t,  # csize : UINT_PTR
    ctypes.c_ubyte,  # ownsData : BYTE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MSAJApi.dll')
alljoyn_abouticon_setcontent = Fiddle::Function.new(
  lib['alljoyn_abouticon_setcontent'],
  [
    Fiddle::TYPE_INTPTR_T,  # icon : alljoyn_abouticon
    Fiddle::TYPE_VOIDP,  # type : LPCSTR
    Fiddle::TYPE_VOIDP,  # data : BYTE* in/out
    Fiddle::TYPE_UINTPTR_T,  # csize : UINT_PTR
    -Fiddle::TYPE_CHAR,  # ownsData : BYTE
  ],
  Fiddle::TYPE_INT)
#[link(name = "msajapi")]
extern "system" {
    fn alljoyn_abouticon_setcontent(
        icon: isize,  // alljoyn_abouticon
        type: *const u8,  // LPCSTR
        data: *mut u8,  // BYTE* in/out
        csize: usize,  // UINT_PTR
        ownsData: u8  // BYTE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MSAJApi.dll")]
public static extern int alljoyn_abouticon_setcontent(IntPtr icon, [MarshalAs(UnmanagedType.LPStr)] string type, IntPtr data, UIntPtr csize, byte ownsData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSAJApi_alljoyn_abouticon_setcontent' -Namespace Win32 -PassThru
# $api::alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
#uselib "MSAJApi.dll"
#func global alljoyn_abouticon_setcontent "alljoyn_abouticon_setcontent" sptr, sptr, sptr, sptr, sptr
; alljoyn_abouticon_setcontent icon, type, varptr(data), csize, ownsData   ; 戻り値は stat
; icon : alljoyn_abouticon -> "sptr"
; type : LPCSTR -> "sptr"
; data : BYTE* in/out -> "sptr"
; csize : UINT_PTR -> "sptr"
; ownsData : BYTE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MSAJApi.dll"
#cfunc global alljoyn_abouticon_setcontent "alljoyn_abouticon_setcontent" sptr, str, var, sptr, int
; res = alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
; icon : alljoyn_abouticon -> "sptr"
; type : LPCSTR -> "str"
; data : BYTE* in/out -> "var"
; csize : UINT_PTR -> "sptr"
; ownsData : BYTE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; QStatus alljoyn_abouticon_setcontent(alljoyn_abouticon icon, LPCSTR type, BYTE* data, UINT_PTR csize, BYTE ownsData)
#uselib "MSAJApi.dll"
#cfunc global alljoyn_abouticon_setcontent "alljoyn_abouticon_setcontent" intptr, str, var, intptr, int
; res = alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
; icon : alljoyn_abouticon -> "intptr"
; type : LPCSTR -> "str"
; data : BYTE* in/out -> "var"
; csize : UINT_PTR -> "intptr"
; ownsData : BYTE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msajapi = windows.NewLazySystemDLL("MSAJApi.dll")
	procalljoyn_abouticon_setcontent = msajapi.NewProc("alljoyn_abouticon_setcontent")
)

// icon (alljoyn_abouticon), type (LPCSTR), data (BYTE* in/out), csize (UINT_PTR), ownsData (BYTE)
r1, _, err := procalljoyn_abouticon_setcontent.Call(
	uintptr(icon),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(type))),
	uintptr(data),
	uintptr(csize),
	uintptr(ownsData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // QStatus
function alljoyn_abouticon_setcontent(
  icon: NativeInt;   // alljoyn_abouticon
  type: PAnsiChar;   // LPCSTR
  data: Pointer;   // BYTE* in/out
  csize: NativeUInt;   // UINT_PTR
  ownsData: Byte   // BYTE
): Integer; stdcall;
  external 'MSAJApi.dll' name 'alljoyn_abouticon_setcontent';
result := DllCall("MSAJApi\alljoyn_abouticon_setcontent"
    , "Ptr", icon   ; alljoyn_abouticon
    , "AStr", type   ; LPCSTR
    , "Ptr", data   ; BYTE* in/out
    , "UPtr", csize   ; UINT_PTR
    , "UChar", ownsData   ; BYTE
    , "Int")   ; return: QStatus
●alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData) = DLL("MSAJApi.dll", "int alljoyn_abouticon_setcontent(int, char*, void*, int, byte)")
# 呼び出し: alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
# icon : alljoyn_abouticon -> "int"
# type : LPCSTR -> "char*"
# data : BYTE* in/out -> "void*"
# csize : UINT_PTR -> "int"
# ownsData : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "msajapi" fn alljoyn_abouticon_setcontent(
    icon: isize, // alljoyn_abouticon
    type: [*c]const u8, // LPCSTR
    data: [*c]u8, // BYTE* in/out
    csize: usize, // UINT_PTR
    ownsData: u8 // BYTE
) callconv(std.os.windows.WINAPI) i32;
proc alljoyn_abouticon_setcontent(
    icon: int,  # alljoyn_abouticon
    `type`: cstring,  # LPCSTR
    data: ptr uint8,  # BYTE* in/out
    csize: uint,  # UINT_PTR
    ownsData: uint8  # BYTE
): int32 {.importc: "alljoyn_abouticon_setcontent", stdcall, dynlib: "MSAJApi.dll".}
pragma(lib, "msajapi");
extern(Windows)
int alljoyn_abouticon_setcontent(
    ptrdiff_t icon,   // alljoyn_abouticon
    const(char)* type,   // LPCSTR
    ubyte* data,   // BYTE* in/out
    size_t csize,   // UINT_PTR
    ubyte ownsData   // BYTE
);
ccall((:alljoyn_abouticon_setcontent, "MSAJApi.dll"), stdcall, Int32,
      (Int, Cstring, Ptr{UInt8}, Csize_t, UInt8),
      icon, type, data, csize, ownsData)
# icon : alljoyn_abouticon -> Int
# type : LPCSTR -> Cstring
# data : BYTE* in/out -> Ptr{UInt8}
# csize : UINT_PTR -> Csize_t
# ownsData : BYTE -> UInt8
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t alljoyn_abouticon_setcontent(
    intptr_t icon,
    const char* type,
    uint8_t* data,
    uintptr_t csize,
    uint8_t ownsData);
]]
local msajapi = ffi.load("msajapi")
-- msajapi.alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
-- icon : alljoyn_abouticon
-- type : LPCSTR
-- data : BYTE* in/out
-- csize : UINT_PTR
-- ownsData : BYTE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MSAJApi.dll');
const alljoyn_abouticon_setcontent = lib.func('__stdcall', 'alljoyn_abouticon_setcontent', 'int32_t', ['intptr_t', 'str', 'uint8_t *', 'uintptr_t', 'uint8_t']);
// alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
// icon : alljoyn_abouticon -> 'intptr_t'
// type : LPCSTR -> 'str'
// data : BYTE* in/out -> 'uint8_t *'
// csize : UINT_PTR -> 'uintptr_t'
// ownsData : BYTE -> 'uint8_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MSAJApi.dll", {
  alljoyn_abouticon_setcontent: { parameters: ["isize", "buffer", "pointer", "usize", "u8"], result: "i32" },
});
// lib.symbols.alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData)
// icon : alljoyn_abouticon -> "isize"
// type : LPCSTR -> "buffer"
// data : BYTE* in/out -> "pointer"
// csize : UINT_PTR -> "usize"
// ownsData : BYTE -> "u8"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t alljoyn_abouticon_setcontent(
    intptr_t icon,
    const char* type,
    uint8_t* data,
    size_t csize,
    uint8_t ownsData);
C, "MSAJApi.dll");
// $ffi->alljoyn_abouticon_setcontent(icon, type, data, csize, ownsData);
// icon : alljoyn_abouticon
// type : LPCSTR
// data : BYTE* in/out
// csize : UINT_PTR
// ownsData : BYTE
// 構造体/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 Msajapi extends StdCallLibrary {
    Msajapi INSTANCE = Native.load("msajapi", Msajapi.class);
    int alljoyn_abouticon_setcontent(
        long icon,   // alljoyn_abouticon
        String type,   // LPCSTR
        byte[] data,   // BYTE* in/out
        long csize,   // UINT_PTR
        byte ownsData   // BYTE
    );
}
@[Link("msajapi")]
lib LibMSAJApi
  fun alljoyn_abouticon_setcontent = alljoyn_abouticon_setcontent(
    icon : LibC::SSizeT,   # alljoyn_abouticon
    type_ : UInt8*,   # LPCSTR
    data : UInt8*,   # BYTE* in/out
    csize : LibC::SizeT,   # UINT_PTR
    ownsData : UInt8   # BYTE
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef alljoyn_abouticon_setcontentNative = Int32 Function(IntPtr, Pointer<Utf8>, Pointer<Uint8>, UintPtr, Uint8);
typedef alljoyn_abouticon_setcontentDart = int Function(int, Pointer<Utf8>, Pointer<Uint8>, int, int);
final alljoyn_abouticon_setcontent = DynamicLibrary.open('MSAJApi.dll')
    .lookupFunction<alljoyn_abouticon_setcontentNative, alljoyn_abouticon_setcontentDart>('alljoyn_abouticon_setcontent');
// icon : alljoyn_abouticon -> IntPtr
// type : LPCSTR -> Pointer<Utf8>
// data : BYTE* in/out -> Pointer<Uint8>
// csize : UINT_PTR -> UintPtr
// ownsData : BYTE -> Uint8
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function alljoyn_abouticon_setcontent(
  icon: NativeInt;   // alljoyn_abouticon
  type: PAnsiChar;   // LPCSTR
  data: Pointer;   // BYTE* in/out
  csize: NativeUInt;   // UINT_PTR
  ownsData: Byte   // BYTE
): Integer; stdcall;
  external 'MSAJApi.dll' name 'alljoyn_abouticon_setcontent';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "alljoyn_abouticon_setcontent"
  c_alljoyn_abouticon_setcontent :: CIntPtr -> CString -> Ptr Word8 -> CUIntPtr -> Word8 -> IO Int32
-- icon : alljoyn_abouticon -> CIntPtr
-- type : LPCSTR -> CString
-- data : BYTE* in/out -> Ptr Word8
-- csize : UINT_PTR -> CUIntPtr
-- ownsData : BYTE -> Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let alljoyn_abouticon_setcontent =
  foreign "alljoyn_abouticon_setcontent"
    (intptr_t @-> string @-> (ptr uint8_t) @-> size_t @-> uint8_t @-> returning int32_t)
(* icon : alljoyn_abouticon -> intptr_t *)
(* type : LPCSTR -> string *)
(* data : BYTE* in/out -> (ptr uint8_t) *)
(* csize : UINT_PTR -> size_t *)
(* ownsData : BYTE -> uint8_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msajapi (t "MSAJApi.dll"))
(cffi:use-foreign-library msajapi)

(cffi:defcfun ("alljoyn_abouticon_setcontent" alljoyn-abouticon-setcontent :convention :stdcall) :int32
  (icon :int64)   ; alljoyn_abouticon
  (type :string)   ; LPCSTR
  (data :pointer)   ; BYTE* in/out
  (csize :uint64)   ; UINT_PTR
  (owns-data :uint8))   ; BYTE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $alljoyn_abouticon_setcontent = Win32::API::More->new('MSAJApi',
    'int alljoyn_abouticon_setcontent(LPARAM icon, LPCSTR type, LPVOID data, WPARAM csize, BYTE ownsData)');
# my $ret = $alljoyn_abouticon_setcontent->Call($icon, $type, $data, $csize, $ownsData);
# icon : alljoyn_abouticon -> LPARAM
# type : LPCSTR -> LPCSTR
# data : BYTE* in/out -> LPVOID
# csize : UINT_PTR -> WPARAM
# ownsData : BYTE -> BYTE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型