SHGetUnreadMailCountW
関数指定アカウントの未読メール件数を取得する。
シグネチャ
// SHELL32.dll (Unicode / -W)
#include <windows.h>
HRESULT SHGetUnreadMailCountW(
HKEY hKeyUser, // optional
LPCWSTR pszMailAddress, // optional
DWORD* pdwCount, // optional
FILETIME* pFileTime, // optional
LPWSTR pszShellExecuteCommand, // optional
INT cchShellExecuteCommand
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hKeyUser | HKEY | inoptional | 指定したユーザーに対応する有効な HKEY。この関数がユーザー環境内で呼び出される場合、このパラメーターは NULL にする必要があり、その場合は HKEY_CURRENT_USER が使用されます。この関数が SYSTEM コンテキストから呼び出される場合も、このパラメーターは NULL にする必要があり、その場合は HKEY_USERS\{SID} が使用されます。 |
| pszMailAddress | LPCWSTR | inoptional | 指定したユーザーに属するアカウントの電子メールアドレスを指定する、Unicode 文字列へのポインター。このパラメーターが NULL の場合、pdwCount には指定したユーザーが所有するすべてのアカウントの未読メッセージ総数が返されます。 |
| pdwCount | DWORD* | outoptional | 未読メッセージ数を受け取る DWORD 値へのポインター。 |
| pFileTime | FILETIME* | outoptional | FILETIME 構造体へのポインター。このパラメーターの用途は、pszMailAddress が NULL かどうかによって決まります。pszMailAddress が NULL の場合、このパラメーターは [in] パラメーターとして扱われ、フィルターを指定します。これにより、指定した時刻より新しい未読メールのみが対象になります。pszMailAddress が NULL でない場合、このパラメーターは [out] パラメーターとして扱われ、FILETIME 構造体を指します。この関数は、指定したユーザーおよび電子メールアカウントに対する最後の SHSetUnreadMailCount 呼び出しの タイムスタンプ を、その構造体に格納します。 |
| pszShellExecuteCommand | LPWSTR | outoptional | 指定したユーザーおよび電子メールアカウントに対する最後の SHSetUnreadMailCount 呼び出しに渡された ShellExecute コマンド文を返す文字列へのポインター。このコマンド文字列は、pszMailAddress で参照されるアカウントを所有する電子メールアプリケーションを起動します。ShellExecute コマンドが不要な場合、このパラメーターは NULL にできます。pszMailAddress が NULL の場合、このパラメーターは無視され、NULL にする必要があります。 |
| cchShellExecuteCommand | INT | in | pszShellExecuteCommand が指す ShellExecute コマンドバッファーの最大サイズ(文字数)。pszMailAddress が NULL の総数取得の場合、このパラメーターは 0 にする必要があります。また、ShellExecute コマンド文字列が不要な場合は NULL にすることもできます。 |
戻り値の型: HRESULT
公式ドキュメント
指定したユーザーの、いずれかまたはすべての電子メールアカウントにおける未読メッセージ数を取得します。(Unicode)
戻り値
Type: HRESULT
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHELL32.dll (Unicode / -W)
#include <windows.h>
HRESULT SHGetUnreadMailCountW(
HKEY hKeyUser, // optional
LPCWSTR pszMailAddress, // optional
DWORD* pdwCount, // optional
FILETIME* pFileTime, // optional
LPWSTR pszShellExecuteCommand, // optional
INT cchShellExecuteCommand
);[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SHGetUnreadMailCountW(
IntPtr hKeyUser, // HKEY optional
[MarshalAs(UnmanagedType.LPWStr)] string pszMailAddress, // LPCWSTR optional
IntPtr pdwCount, // DWORD* optional, out
IntPtr pFileTime, // FILETIME* optional, out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszShellExecuteCommand, // LPWSTR optional, out
int cchShellExecuteCommand // INT
);<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SHGetUnreadMailCountW(
hKeyUser As IntPtr, ' HKEY optional
<MarshalAs(UnmanagedType.LPWStr)> pszMailAddress As String, ' LPCWSTR optional
pdwCount As IntPtr, ' DWORD* optional, out
pFileTime As IntPtr, ' FILETIME* optional, out
<MarshalAs(UnmanagedType.LPWStr)> pszShellExecuteCommand As System.Text.StringBuilder, ' LPWSTR optional, out
cchShellExecuteCommand As Integer ' INT
) As Integer
End Function' hKeyUser : HKEY optional
' pszMailAddress : LPCWSTR optional
' pdwCount : DWORD* optional, out
' pFileTime : FILETIME* optional, out
' pszShellExecuteCommand : LPWSTR optional, out
' cchShellExecuteCommand : INT
Declare PtrSafe Function SHGetUnreadMailCountW Lib "shell32" ( _
ByVal hKeyUser As LongPtr, _
ByVal pszMailAddress As LongPtr, _
ByVal pdwCount As LongPtr, _
ByVal pFileTime As LongPtr, _
ByVal pszShellExecuteCommand As LongPtr, _
ByVal cchShellExecuteCommand As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHGetUnreadMailCountW = ctypes.windll.shell32.SHGetUnreadMailCountW
SHGetUnreadMailCountW.restype = ctypes.c_int
SHGetUnreadMailCountW.argtypes = [
wintypes.HANDLE, # hKeyUser : HKEY optional
wintypes.LPCWSTR, # pszMailAddress : LPCWSTR optional
ctypes.POINTER(wintypes.DWORD), # pdwCount : DWORD* optional, out
ctypes.c_void_p, # pFileTime : FILETIME* optional, out
wintypes.LPWSTR, # pszShellExecuteCommand : LPWSTR optional, out
ctypes.c_int, # cchShellExecuteCommand : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHGetUnreadMailCountW = Fiddle::Function.new(
lib['SHGetUnreadMailCountW'],
[
Fiddle::TYPE_VOIDP, # hKeyUser : HKEY optional
Fiddle::TYPE_VOIDP, # pszMailAddress : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pdwCount : DWORD* optional, out
Fiddle::TYPE_VOIDP, # pFileTime : FILETIME* optional, out
Fiddle::TYPE_VOIDP, # pszShellExecuteCommand : LPWSTR optional, out
Fiddle::TYPE_INT, # cchShellExecuteCommand : INT
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shell32")]
extern "system" {
fn SHGetUnreadMailCountW(
hKeyUser: *mut core::ffi::c_void, // HKEY optional
pszMailAddress: *const u16, // LPCWSTR optional
pdwCount: *mut u32, // DWORD* optional, out
pFileTime: *mut FILETIME, // FILETIME* optional, out
pszShellExecuteCommand: *mut u16, // LPWSTR optional, out
cchShellExecuteCommand: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern int SHGetUnreadMailCountW(IntPtr hKeyUser, [MarshalAs(UnmanagedType.LPWStr)] string pszMailAddress, IntPtr pdwCount, IntPtr pFileTime, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszShellExecuteCommand, int cchShellExecuteCommand);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHGetUnreadMailCountW' -Namespace Win32 -PassThru
# $api::SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)#uselib "SHELL32.dll"
#func global SHGetUnreadMailCountW "SHGetUnreadMailCountW" wptr, wptr, wptr, wptr, wptr, wptr
; SHGetUnreadMailCountW hKeyUser, pszMailAddress, varptr(pdwCount), varptr(pFileTime), varptr(pszShellExecuteCommand), cchShellExecuteCommand ; 戻り値は stat
; hKeyUser : HKEY optional -> "wptr"
; pszMailAddress : LPCWSTR optional -> "wptr"
; pdwCount : DWORD* optional, out -> "wptr"
; pFileTime : FILETIME* optional, out -> "wptr"
; pszShellExecuteCommand : LPWSTR optional, out -> "wptr"
; cchShellExecuteCommand : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHGetUnreadMailCountW "SHGetUnreadMailCountW" sptr, wstr, var, var, var, int ; res = SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand) ; hKeyUser : HKEY optional -> "sptr" ; pszMailAddress : LPCWSTR optional -> "wstr" ; pdwCount : DWORD* optional, out -> "var" ; pFileTime : FILETIME* optional, out -> "var" ; pszShellExecuteCommand : LPWSTR optional, out -> "var" ; cchShellExecuteCommand : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHGetUnreadMailCountW "SHGetUnreadMailCountW" sptr, wstr, sptr, sptr, sptr, int ; res = SHGetUnreadMailCountW(hKeyUser, pszMailAddress, varptr(pdwCount), varptr(pFileTime), varptr(pszShellExecuteCommand), cchShellExecuteCommand) ; hKeyUser : HKEY optional -> "sptr" ; pszMailAddress : LPCWSTR optional -> "wstr" ; pdwCount : DWORD* optional, out -> "sptr" ; pFileTime : FILETIME* optional, out -> "sptr" ; pszShellExecuteCommand : LPWSTR optional, out -> "sptr" ; cchShellExecuteCommand : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SHGetUnreadMailCountW(HKEY hKeyUser, LPCWSTR pszMailAddress, DWORD* pdwCount, FILETIME* pFileTime, LPWSTR pszShellExecuteCommand, INT cchShellExecuteCommand) #uselib "SHELL32.dll" #cfunc global SHGetUnreadMailCountW "SHGetUnreadMailCountW" intptr, wstr, var, var, var, int ; res = SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand) ; hKeyUser : HKEY optional -> "intptr" ; pszMailAddress : LPCWSTR optional -> "wstr" ; pdwCount : DWORD* optional, out -> "var" ; pFileTime : FILETIME* optional, out -> "var" ; pszShellExecuteCommand : LPWSTR optional, out -> "var" ; cchShellExecuteCommand : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SHGetUnreadMailCountW(HKEY hKeyUser, LPCWSTR pszMailAddress, DWORD* pdwCount, FILETIME* pFileTime, LPWSTR pszShellExecuteCommand, INT cchShellExecuteCommand) #uselib "SHELL32.dll" #cfunc global SHGetUnreadMailCountW "SHGetUnreadMailCountW" intptr, wstr, intptr, intptr, intptr, int ; res = SHGetUnreadMailCountW(hKeyUser, pszMailAddress, varptr(pdwCount), varptr(pFileTime), varptr(pszShellExecuteCommand), cchShellExecuteCommand) ; hKeyUser : HKEY optional -> "intptr" ; pszMailAddress : LPCWSTR optional -> "wstr" ; pdwCount : DWORD* optional, out -> "intptr" ; pFileTime : FILETIME* optional, out -> "intptr" ; pszShellExecuteCommand : LPWSTR optional, out -> "intptr" ; cchShellExecuteCommand : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHGetUnreadMailCountW = shell32.NewProc("SHGetUnreadMailCountW")
)
// hKeyUser (HKEY optional), pszMailAddress (LPCWSTR optional), pdwCount (DWORD* optional, out), pFileTime (FILETIME* optional, out), pszShellExecuteCommand (LPWSTR optional, out), cchShellExecuteCommand (INT)
r1, _, err := procSHGetUnreadMailCountW.Call(
uintptr(hKeyUser),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMailAddress))),
uintptr(pdwCount),
uintptr(pFileTime),
uintptr(pszShellExecuteCommand),
uintptr(cchShellExecuteCommand),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHGetUnreadMailCountW(
hKeyUser: THandle; // HKEY optional
pszMailAddress: PWideChar; // LPCWSTR optional
pdwCount: Pointer; // DWORD* optional, out
pFileTime: Pointer; // FILETIME* optional, out
pszShellExecuteCommand: PWideChar; // LPWSTR optional, out
cchShellExecuteCommand: Integer // INT
): Integer; stdcall;
external 'SHELL32.dll' name 'SHGetUnreadMailCountW';result := DllCall("SHELL32\SHGetUnreadMailCountW"
, "Ptr", hKeyUser ; HKEY optional
, "WStr", pszMailAddress ; LPCWSTR optional
, "Ptr", pdwCount ; DWORD* optional, out
, "Ptr", pFileTime ; FILETIME* optional, out
, "Ptr", pszShellExecuteCommand ; LPWSTR optional, out
, "Int", cchShellExecuteCommand ; INT
, "Int") ; return: HRESULT●SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand) = DLL("SHELL32.dll", "int SHGetUnreadMailCountW(void*, char*, void*, void*, char*, int)")
# 呼び出し: SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)
# hKeyUser : HKEY optional -> "void*"
# pszMailAddress : LPCWSTR optional -> "char*"
# pdwCount : DWORD* optional, out -> "void*"
# pFileTime : FILETIME* optional, out -> "void*"
# pszShellExecuteCommand : LPWSTR optional, out -> "char*"
# cchShellExecuteCommand : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "shell32" fn SHGetUnreadMailCountW(
hKeyUser: ?*anyopaque, // HKEY optional
pszMailAddress: [*c]const u16, // LPCWSTR optional
pdwCount: [*c]u32, // DWORD* optional, out
pFileTime: [*c]FILETIME, // FILETIME* optional, out
pszShellExecuteCommand: [*c]u16, // LPWSTR optional, out
cchShellExecuteCommand: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SHGetUnreadMailCountW(
hKeyUser: pointer, # HKEY optional
pszMailAddress: WideCString, # LPCWSTR optional
pdwCount: ptr uint32, # DWORD* optional, out
pFileTime: ptr FILETIME, # FILETIME* optional, out
pszShellExecuteCommand: ptr uint16, # LPWSTR optional, out
cchShellExecuteCommand: int32 # INT
): int32 {.importc: "SHGetUnreadMailCountW", stdcall, dynlib: "SHELL32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "shell32");
extern(Windows)
int SHGetUnreadMailCountW(
void* hKeyUser, // HKEY optional
const(wchar)* pszMailAddress, // LPCWSTR optional
uint* pdwCount, // DWORD* optional, out
FILETIME* pFileTime, // FILETIME* optional, out
wchar* pszShellExecuteCommand, // LPWSTR optional, out
int cchShellExecuteCommand // INT
);ccall((:SHGetUnreadMailCountW, "SHELL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Ptr{UInt32}, Ptr{FILETIME}, Ptr{UInt16}, Int32),
hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)
# hKeyUser : HKEY optional -> Ptr{Cvoid}
# pszMailAddress : LPCWSTR optional -> Cwstring
# pdwCount : DWORD* optional, out -> Ptr{UInt32}
# pFileTime : FILETIME* optional, out -> Ptr{FILETIME}
# pszShellExecuteCommand : LPWSTR optional, out -> Ptr{UInt16}
# cchShellExecuteCommand : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SHGetUnreadMailCountW(
void* hKeyUser,
const uint16_t* pszMailAddress,
uint32_t* pdwCount,
void* pFileTime,
uint16_t* pszShellExecuteCommand,
int32_t cchShellExecuteCommand);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)
-- hKeyUser : HKEY optional
-- pszMailAddress : LPCWSTR optional
-- pdwCount : DWORD* optional, out
-- pFileTime : FILETIME* optional, out
-- pszShellExecuteCommand : LPWSTR optional, out
-- cchShellExecuteCommand : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHGetUnreadMailCountW = lib.func('__stdcall', 'SHGetUnreadMailCountW', 'int32_t', ['void *', 'str16', 'uint32_t *', 'void *', 'uint16_t *', 'int32_t']);
// SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)
// hKeyUser : HKEY optional -> 'void *'
// pszMailAddress : LPCWSTR optional -> 'str16'
// pdwCount : DWORD* optional, out -> 'uint32_t *'
// pFileTime : FILETIME* optional, out -> 'void *'
// pszShellExecuteCommand : LPWSTR optional, out -> 'uint16_t *'
// cchShellExecuteCommand : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHGetUnreadMailCountW: { parameters: ["pointer", "buffer", "pointer", "pointer", "buffer", "i32"], result: "i32" },
});
// lib.symbols.SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand)
// hKeyUser : HKEY optional -> "pointer"
// pszMailAddress : LPCWSTR optional -> "buffer"
// pdwCount : DWORD* optional, out -> "pointer"
// pFileTime : FILETIME* optional, out -> "pointer"
// pszShellExecuteCommand : LPWSTR optional, out -> "buffer"
// cchShellExecuteCommand : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SHGetUnreadMailCountW(
void* hKeyUser,
const uint16_t* pszMailAddress,
uint32_t* pdwCount,
void* pFileTime,
uint16_t* pszShellExecuteCommand,
int32_t cchShellExecuteCommand);
C, "SHELL32.dll");
// $ffi->SHGetUnreadMailCountW(hKeyUser, pszMailAddress, pdwCount, pFileTime, pszShellExecuteCommand, cchShellExecuteCommand);
// hKeyUser : HKEY optional
// pszMailAddress : LPCWSTR optional
// pdwCount : DWORD* optional, out
// pFileTime : FILETIME* optional, out
// pszShellExecuteCommand : LPWSTR optional, out
// cchShellExecuteCommand : INT
// 構造体/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 Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class, W32APIOptions.UNICODE_OPTIONS);
int SHGetUnreadMailCountW(
Pointer hKeyUser, // HKEY optional
WString pszMailAddress, // LPCWSTR optional
IntByReference pdwCount, // DWORD* optional, out
Pointer pFileTime, // FILETIME* optional, out
char[] pszShellExecuteCommand, // LPWSTR optional, out
int cchShellExecuteCommand // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("shell32")]
lib LibSHELL32
fun SHGetUnreadMailCountW = SHGetUnreadMailCountW(
hKeyUser : Void*, # HKEY optional
pszMailAddress : UInt16*, # LPCWSTR optional
pdwCount : UInt32*, # DWORD* optional, out
pFileTime : FILETIME*, # FILETIME* optional, out
pszShellExecuteCommand : UInt16*, # LPWSTR optional, out
cchShellExecuteCommand : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHGetUnreadMailCountWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>, Pointer<Utf16>, Int32);
typedef SHGetUnreadMailCountWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>, Pointer<Utf16>, int);
final SHGetUnreadMailCountW = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHGetUnreadMailCountWNative, SHGetUnreadMailCountWDart>('SHGetUnreadMailCountW');
// hKeyUser : HKEY optional -> Pointer<Void>
// pszMailAddress : LPCWSTR optional -> Pointer<Utf16>
// pdwCount : DWORD* optional, out -> Pointer<Uint32>
// pFileTime : FILETIME* optional, out -> Pointer<Void>
// pszShellExecuteCommand : LPWSTR optional, out -> Pointer<Utf16>
// cchShellExecuteCommand : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHGetUnreadMailCountW(
hKeyUser: THandle; // HKEY optional
pszMailAddress: PWideChar; // LPCWSTR optional
pdwCount: Pointer; // DWORD* optional, out
pFileTime: Pointer; // FILETIME* optional, out
pszShellExecuteCommand: PWideChar; // LPWSTR optional, out
cchShellExecuteCommand: Integer // INT
): Integer; stdcall;
external 'SHELL32.dll' name 'SHGetUnreadMailCountW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHGetUnreadMailCountW"
c_SHGetUnreadMailCountW :: Ptr () -> CWString -> Ptr Word32 -> Ptr () -> CWString -> Int32 -> IO Int32
-- hKeyUser : HKEY optional -> Ptr ()
-- pszMailAddress : LPCWSTR optional -> CWString
-- pdwCount : DWORD* optional, out -> Ptr Word32
-- pFileTime : FILETIME* optional, out -> Ptr ()
-- pszShellExecuteCommand : LPWSTR optional, out -> CWString
-- cchShellExecuteCommand : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shgetunreadmailcountw =
foreign "SHGetUnreadMailCountW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr void) @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* hKeyUser : HKEY optional -> (ptr void) *)
(* pszMailAddress : LPCWSTR optional -> (ptr uint16_t) *)
(* pdwCount : DWORD* optional, out -> (ptr uint32_t) *)
(* pFileTime : FILETIME* optional, out -> (ptr void) *)
(* pszShellExecuteCommand : LPWSTR optional, out -> (ptr uint16_t) *)
(* cchShellExecuteCommand : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHGetUnreadMailCountW" shget-unread-mail-count-w :convention :stdcall) :int32
(h-key-user :pointer) ; HKEY optional
(psz-mail-address (:string :encoding :utf-16le)) ; LPCWSTR optional
(pdw-count :pointer) ; DWORD* optional, out
(p-file-time :pointer) ; FILETIME* optional, out
(psz-shell-execute-command :pointer) ; LPWSTR optional, out
(cch-shell-execute-command :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHGetUnreadMailCountW = Win32::API::More->new('SHELL32',
'int SHGetUnreadMailCountW(HANDLE hKeyUser, LPCWSTR pszMailAddress, LPVOID pdwCount, LPVOID pFileTime, LPWSTR pszShellExecuteCommand, int cchShellExecuteCommand)');
# my $ret = $SHGetUnreadMailCountW->Call($hKeyUser, $pszMailAddress, $pdwCount, $pFileTime, $pszShellExecuteCommand, $cchShellExecuteCommand);
# hKeyUser : HKEY optional -> HANDLE
# pszMailAddress : LPCWSTR optional -> LPCWSTR
# pdwCount : DWORD* optional, out -> LPVOID
# pFileTime : FILETIME* optional, out -> LPVOID
# pszShellExecuteCommand : LPWSTR optional, out -> LPWSTR
# cchShellExecuteCommand : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
使用する型