ホーム › Web.InternetExplorer › IdentifyMIMEType
IdentifyMIMEType
関数先頭バイト列からデータのMIMEフォーマット種別を識別する。
シグネチャ
// ImgUtil.dll
#include <windows.h>
HRESULT IdentifyMIMEType(
const BYTE* pbBytes,
DWORD nBytes,
DWORD* pnFormat
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pbBytes | BYTE* | in |
| nBytes | DWORD | in |
| pnFormat | DWORD* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// ImgUtil.dll
#include <windows.h>
HRESULT IdentifyMIMEType(
const BYTE* pbBytes,
DWORD nBytes,
DWORD* pnFormat
);[DllImport("ImgUtil.dll", ExactSpelling = true)]
static extern int IdentifyMIMEType(
IntPtr pbBytes, // BYTE*
uint nBytes, // DWORD
ref uint pnFormat // DWORD* in/out
);<DllImport("ImgUtil.dll", ExactSpelling:=True)>
Public Shared Function IdentifyMIMEType(
pbBytes As IntPtr, ' BYTE*
nBytes As UInteger, ' DWORD
ByRef pnFormat As UInteger ' DWORD* in/out
) As Integer
End Function' pbBytes : BYTE*
' nBytes : DWORD
' pnFormat : DWORD* in/out
Declare PtrSafe Function IdentifyMIMEType Lib "imgutil" ( _
ByVal pbBytes As LongPtr, _
ByVal nBytes As Long, _
ByRef pnFormat As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IdentifyMIMEType = ctypes.windll.imgutil.IdentifyMIMEType
IdentifyMIMEType.restype = ctypes.c_int
IdentifyMIMEType.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # pbBytes : BYTE*
wintypes.DWORD, # nBytes : DWORD
ctypes.POINTER(wintypes.DWORD), # pnFormat : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ImgUtil.dll')
IdentifyMIMEType = Fiddle::Function.new(
lib['IdentifyMIMEType'],
[
Fiddle::TYPE_VOIDP, # pbBytes : BYTE*
-Fiddle::TYPE_INT, # nBytes : DWORD
Fiddle::TYPE_VOIDP, # pnFormat : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "imgutil")]
extern "system" {
fn IdentifyMIMEType(
pbBytes: *const u8, // BYTE*
nBytes: u32, // DWORD
pnFormat: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ImgUtil.dll")]
public static extern int IdentifyMIMEType(IntPtr pbBytes, uint nBytes, ref uint pnFormat);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ImgUtil_IdentifyMIMEType' -Namespace Win32 -PassThru
# $api::IdentifyMIMEType(pbBytes, nBytes, pnFormat)#uselib "ImgUtil.dll"
#func global IdentifyMIMEType "IdentifyMIMEType" sptr, sptr, sptr
; IdentifyMIMEType varptr(pbBytes), nBytes, varptr(pnFormat) ; 戻り値は stat
; pbBytes : BYTE* -> "sptr"
; nBytes : DWORD -> "sptr"
; pnFormat : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ImgUtil.dll" #cfunc global IdentifyMIMEType "IdentifyMIMEType" var, int, var ; res = IdentifyMIMEType(pbBytes, nBytes, pnFormat) ; pbBytes : BYTE* -> "var" ; nBytes : DWORD -> "int" ; pnFormat : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ImgUtil.dll" #cfunc global IdentifyMIMEType "IdentifyMIMEType" sptr, int, sptr ; res = IdentifyMIMEType(varptr(pbBytes), nBytes, varptr(pnFormat)) ; pbBytes : BYTE* -> "sptr" ; nBytes : DWORD -> "int" ; pnFormat : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT IdentifyMIMEType(BYTE* pbBytes, DWORD nBytes, DWORD* pnFormat) #uselib "ImgUtil.dll" #cfunc global IdentifyMIMEType "IdentifyMIMEType" var, int, var ; res = IdentifyMIMEType(pbBytes, nBytes, pnFormat) ; pbBytes : BYTE* -> "var" ; nBytes : DWORD -> "int" ; pnFormat : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT IdentifyMIMEType(BYTE* pbBytes, DWORD nBytes, DWORD* pnFormat) #uselib "ImgUtil.dll" #cfunc global IdentifyMIMEType "IdentifyMIMEType" intptr, int, intptr ; res = IdentifyMIMEType(varptr(pbBytes), nBytes, varptr(pnFormat)) ; pbBytes : BYTE* -> "intptr" ; nBytes : DWORD -> "int" ; pnFormat : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imgutil = windows.NewLazySystemDLL("ImgUtil.dll")
procIdentifyMIMEType = imgutil.NewProc("IdentifyMIMEType")
)
// pbBytes (BYTE*), nBytes (DWORD), pnFormat (DWORD* in/out)
r1, _, err := procIdentifyMIMEType.Call(
uintptr(pbBytes),
uintptr(nBytes),
uintptr(pnFormat),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction IdentifyMIMEType(
pbBytes: Pointer; // BYTE*
nBytes: DWORD; // DWORD
pnFormat: Pointer // DWORD* in/out
): Integer; stdcall;
external 'ImgUtil.dll' name 'IdentifyMIMEType';result := DllCall("ImgUtil\IdentifyMIMEType"
, "Ptr", pbBytes ; BYTE*
, "UInt", nBytes ; DWORD
, "Ptr", pnFormat ; DWORD* in/out
, "Int") ; return: HRESULT●IdentifyMIMEType(pbBytes, nBytes, pnFormat) = DLL("ImgUtil.dll", "int IdentifyMIMEType(void*, dword, void*)")
# 呼び出し: IdentifyMIMEType(pbBytes, nBytes, pnFormat)
# pbBytes : BYTE* -> "void*"
# nBytes : DWORD -> "dword"
# pnFormat : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。