ホーム › Devices.Tapi › phoneGetRing
phoneGetRing
関数電話の現在の呼び出しモードと音量を取得する。
シグネチャ
// TAPI32.dll
#include <windows.h>
INT phoneGetRing(
DWORD hPhone,
DWORD* lpdwRingMode,
DWORD* lpdwVolume
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPhone | DWORD | in | 呼出し音設定を取得する対象の電話デバイスのハンドル。 |
| lpdwRingMode | DWORD* | inout | 現在の呼出し音パターン(リングモード)を受け取る出力先ポインタ。 |
| lpdwVolume | DWORD* | inout | 現在の呼出し音量(0x00000000~0x0000FFFF)を受け取る出力先ポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll
#include <windows.h>
INT phoneGetRing(
DWORD hPhone,
DWORD* lpdwRingMode,
DWORD* lpdwVolume
);[DllImport("TAPI32.dll", ExactSpelling = true)]
static extern int phoneGetRing(
uint hPhone, // DWORD
ref uint lpdwRingMode, // DWORD* in/out
ref uint lpdwVolume // DWORD* in/out
);<DllImport("TAPI32.dll", ExactSpelling:=True)>
Public Shared Function phoneGetRing(
hPhone As UInteger, ' DWORD
ByRef lpdwRingMode As UInteger, ' DWORD* in/out
ByRef lpdwVolume As UInteger ' DWORD* in/out
) As Integer
End Function' hPhone : DWORD
' lpdwRingMode : DWORD* in/out
' lpdwVolume : DWORD* in/out
Declare PtrSafe Function phoneGetRing Lib "tapi32" ( _
ByVal hPhone As Long, _
ByRef lpdwRingMode As Long, _
ByRef lpdwVolume As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
phoneGetRing = ctypes.windll.tapi32.phoneGetRing
phoneGetRing.restype = ctypes.c_int
phoneGetRing.argtypes = [
wintypes.DWORD, # hPhone : DWORD
ctypes.POINTER(wintypes.DWORD), # lpdwRingMode : DWORD* in/out
ctypes.POINTER(wintypes.DWORD), # lpdwVolume : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
phoneGetRing = Fiddle::Function.new(
lib['phoneGetRing'],
[
-Fiddle::TYPE_INT, # hPhone : DWORD
Fiddle::TYPE_VOIDP, # lpdwRingMode : DWORD* in/out
Fiddle::TYPE_VOIDP, # lpdwVolume : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "tapi32")]
extern "system" {
fn phoneGetRing(
hPhone: u32, // DWORD
lpdwRingMode: *mut u32, // DWORD* in/out
lpdwVolume: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll")]
public static extern int phoneGetRing(uint hPhone, ref uint lpdwRingMode, ref uint lpdwVolume);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_phoneGetRing' -Namespace Win32 -PassThru
# $api::phoneGetRing(hPhone, lpdwRingMode, lpdwVolume)#uselib "TAPI32.dll"
#func global phoneGetRing "phoneGetRing" sptr, sptr, sptr
; phoneGetRing hPhone, varptr(lpdwRingMode), varptr(lpdwVolume) ; 戻り値は stat
; hPhone : DWORD -> "sptr"
; lpdwRingMode : DWORD* in/out -> "sptr"
; lpdwVolume : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global phoneGetRing "phoneGetRing" int, var, var ; res = phoneGetRing(hPhone, lpdwRingMode, lpdwVolume) ; hPhone : DWORD -> "int" ; lpdwRingMode : DWORD* in/out -> "var" ; lpdwVolume : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global phoneGetRing "phoneGetRing" int, sptr, sptr ; res = phoneGetRing(hPhone, varptr(lpdwRingMode), varptr(lpdwVolume)) ; hPhone : DWORD -> "int" ; lpdwRingMode : DWORD* in/out -> "sptr" ; lpdwVolume : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT phoneGetRing(DWORD hPhone, DWORD* lpdwRingMode, DWORD* lpdwVolume) #uselib "TAPI32.dll" #cfunc global phoneGetRing "phoneGetRing" int, var, var ; res = phoneGetRing(hPhone, lpdwRingMode, lpdwVolume) ; hPhone : DWORD -> "int" ; lpdwRingMode : DWORD* in/out -> "var" ; lpdwVolume : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT phoneGetRing(DWORD hPhone, DWORD* lpdwRingMode, DWORD* lpdwVolume) #uselib "TAPI32.dll" #cfunc global phoneGetRing "phoneGetRing" int, intptr, intptr ; res = phoneGetRing(hPhone, varptr(lpdwRingMode), varptr(lpdwVolume)) ; hPhone : DWORD -> "int" ; lpdwRingMode : DWORD* in/out -> "intptr" ; lpdwVolume : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
procphoneGetRing = tapi32.NewProc("phoneGetRing")
)
// hPhone (DWORD), lpdwRingMode (DWORD* in/out), lpdwVolume (DWORD* in/out)
r1, _, err := procphoneGetRing.Call(
uintptr(hPhone),
uintptr(lpdwRingMode),
uintptr(lpdwVolume),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction phoneGetRing(
hPhone: DWORD; // DWORD
lpdwRingMode: Pointer; // DWORD* in/out
lpdwVolume: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'phoneGetRing';result := DllCall("TAPI32\phoneGetRing"
, "UInt", hPhone ; DWORD
, "Ptr", lpdwRingMode ; DWORD* in/out
, "Ptr", lpdwVolume ; DWORD* in/out
, "Int") ; return: INT●phoneGetRing(hPhone, lpdwRingMode, lpdwVolume) = DLL("TAPI32.dll", "int phoneGetRing(dword, void*, void*)")
# 呼び出し: phoneGetRing(hPhone, lpdwRingMode, lpdwVolume)
# hPhone : DWORD -> "dword"
# lpdwRingMode : DWORD* in/out -> "void*"
# lpdwVolume : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "tapi32" fn phoneGetRing(
hPhone: u32, // DWORD
lpdwRingMode: [*c]u32, // DWORD* in/out
lpdwVolume: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc phoneGetRing(
hPhone: uint32, # DWORD
lpdwRingMode: ptr uint32, # DWORD* in/out
lpdwVolume: ptr uint32 # DWORD* in/out
): int32 {.importc: "phoneGetRing", stdcall, dynlib: "TAPI32.dll".}pragma(lib, "tapi32");
extern(Windows)
int phoneGetRing(
uint hPhone, // DWORD
uint* lpdwRingMode, // DWORD* in/out
uint* lpdwVolume // DWORD* in/out
);ccall((:phoneGetRing, "TAPI32.dll"), stdcall, Int32,
(UInt32, Ptr{UInt32}, Ptr{UInt32}),
hPhone, lpdwRingMode, lpdwVolume)
# hPhone : DWORD -> UInt32
# lpdwRingMode : DWORD* in/out -> Ptr{UInt32}
# lpdwVolume : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t phoneGetRing(
uint32_t hPhone,
uint32_t* lpdwRingMode,
uint32_t* lpdwVolume);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.phoneGetRing(hPhone, lpdwRingMode, lpdwVolume)
-- hPhone : DWORD
-- lpdwRingMode : DWORD* in/out
-- lpdwVolume : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('TAPI32.dll');
const phoneGetRing = lib.func('__stdcall', 'phoneGetRing', 'int32_t', ['uint32_t', 'uint32_t *', 'uint32_t *']);
// phoneGetRing(hPhone, lpdwRingMode, lpdwVolume)
// hPhone : DWORD -> 'uint32_t'
// lpdwRingMode : DWORD* in/out -> 'uint32_t *'
// lpdwVolume : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
phoneGetRing: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.phoneGetRing(hPhone, lpdwRingMode, lpdwVolume)
// hPhone : DWORD -> "u32"
// lpdwRingMode : DWORD* in/out -> "pointer"
// lpdwVolume : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t phoneGetRing(
uint32_t hPhone,
uint32_t* lpdwRingMode,
uint32_t* lpdwVolume);
C, "TAPI32.dll");
// $ffi->phoneGetRing(hPhone, lpdwRingMode, lpdwVolume);
// hPhone : DWORD
// lpdwRingMode : DWORD* in/out
// lpdwVolume : DWORD* in/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 Tapi32 extends StdCallLibrary {
Tapi32 INSTANCE = Native.load("tapi32", Tapi32.class);
int phoneGetRing(
int hPhone, // DWORD
IntByReference lpdwRingMode, // DWORD* in/out
IntByReference lpdwVolume // DWORD* in/out
);
}@[Link("tapi32")]
lib LibTAPI32
fun phoneGetRing = phoneGetRing(
hPhone : UInt32, # DWORD
lpdwRingMode : UInt32*, # DWORD* in/out
lpdwVolume : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef phoneGetRingNative = Int32 Function(Uint32, Pointer<Uint32>, Pointer<Uint32>);
typedef phoneGetRingDart = int Function(int, Pointer<Uint32>, Pointer<Uint32>);
final phoneGetRing = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<phoneGetRingNative, phoneGetRingDart>('phoneGetRing');
// hPhone : DWORD -> Uint32
// lpdwRingMode : DWORD* in/out -> Pointer<Uint32>
// lpdwVolume : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function phoneGetRing(
hPhone: DWORD; // DWORD
lpdwRingMode: Pointer; // DWORD* in/out
lpdwVolume: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'phoneGetRing';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "phoneGetRing"
c_phoneGetRing :: Word32 -> Ptr Word32 -> Ptr Word32 -> IO Int32
-- hPhone : DWORD -> Word32
-- lpdwRingMode : DWORD* in/out -> Ptr Word32
-- lpdwVolume : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let phonegetring =
foreign "phoneGetRing"
(uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hPhone : DWORD -> uint32_t *)
(* lpdwRingMode : DWORD* in/out -> (ptr uint32_t) *)
(* lpdwVolume : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library tapi32 (t "TAPI32.dll"))
(cffi:use-foreign-library tapi32)
(cffi:defcfun ("phoneGetRing" phone-get-ring :convention :stdcall) :int32
(h-phone :uint32) ; DWORD
(lpdw-ring-mode :pointer) ; DWORD* in/out
(lpdw-volume :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $phoneGetRing = Win32::API::More->new('TAPI32',
'int phoneGetRing(DWORD hPhone, LPVOID lpdwRingMode, LPVOID lpdwVolume)');
# my $ret = $phoneGetRing->Call($hPhone, $lpdwRingMode, $lpdwVolume);
# hPhone : DWORD -> DWORD
# lpdwRingMode : DWORD* in/out -> LPVOID
# lpdwVolume : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。