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

FaxRegisterRoutingExtensionW

関数
ファクスのルーティング拡張を登録する。
DLLWINFAX.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL FaxRegisterRoutingExtensionW(
    HANDLE FaxHandle,
    LPCWSTR ExtensionName,
    LPCWSTR FriendlyName,
    LPCWSTR ImageName,
    PFAX_ROUTING_INSTALLATION_CALLBACKW CallBack,
    void* Context
);

パラメーター

名前方向説明
FaxHandleHANDLEinFAXサーバー接続のハンドルを指定する。
ExtensionNameLPCWSTRin登録するルーティング拡張の一意な名前を指定する。
FriendlyNameLPCWSTRin表示用の拡張のフレンドリ名を指定する。
ImageNameLPCWSTRin拡張を実装するDLLの実行イメージパスを指定する。
CallBackPFAX_ROUTING_INSTALLATION_CALLBACKWin拡張インストール処理を行うコールバック関数へのポインタを指定する。
Contextvoid*inコールバックに渡す任意のコンテキストポインタを指定する。NULL可。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL FaxRegisterRoutingExtensionW(
    HANDLE FaxHandle,
    LPCWSTR ExtensionName,
    LPCWSTR FriendlyName,
    LPCWSTR ImageName,
    PFAX_ROUTING_INSTALLATION_CALLBACKW CallBack,
    void* Context
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINFAX.dll", SetLastError = true, ExactSpelling = true)]
static extern bool FaxRegisterRoutingExtensionW(
    IntPtr FaxHandle,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string ExtensionName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string FriendlyName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string ImageName,   // LPCWSTR
    IntPtr CallBack,   // PFAX_ROUTING_INSTALLATION_CALLBACKW
    IntPtr Context   // void*
);
<DllImport("WINFAX.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FaxRegisterRoutingExtensionW(
    FaxHandle As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> ExtensionName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> FriendlyName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> ImageName As String,   ' LPCWSTR
    CallBack As IntPtr,   ' PFAX_ROUTING_INSTALLATION_CALLBACKW
    Context As IntPtr   ' void*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' FaxHandle : HANDLE
' ExtensionName : LPCWSTR
' FriendlyName : LPCWSTR
' ImageName : LPCWSTR
' CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW
' Context : void*
Declare PtrSafe Function FaxRegisterRoutingExtensionW Lib "winfax" ( _
    ByVal FaxHandle As LongPtr, _
    ByVal ExtensionName As LongPtr, _
    ByVal FriendlyName As LongPtr, _
    ByVal ImageName As LongPtr, _
    ByVal CallBack As LongPtr, _
    ByVal Context As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FaxRegisterRoutingExtensionW = ctypes.windll.winfax.FaxRegisterRoutingExtensionW
FaxRegisterRoutingExtensionW.restype = wintypes.BOOL
FaxRegisterRoutingExtensionW.argtypes = [
    wintypes.HANDLE,  # FaxHandle : HANDLE
    wintypes.LPCWSTR,  # ExtensionName : LPCWSTR
    wintypes.LPCWSTR,  # FriendlyName : LPCWSTR
    wintypes.LPCWSTR,  # ImageName : LPCWSTR
    ctypes.c_void_p,  # CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW
    ctypes.POINTER(None),  # Context : void*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINFAX.dll')
FaxRegisterRoutingExtensionW = Fiddle::Function.new(
  lib['FaxRegisterRoutingExtensionW'],
  [
    Fiddle::TYPE_VOIDP,  # FaxHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # ExtensionName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # FriendlyName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ImageName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW
    Fiddle::TYPE_VOIDP,  # Context : void*
  ],
  Fiddle::TYPE_INT)
#[link(name = "winfax")]
extern "system" {
    fn FaxRegisterRoutingExtensionW(
        FaxHandle: *mut core::ffi::c_void,  // HANDLE
        ExtensionName: *const u16,  // LPCWSTR
        FriendlyName: *const u16,  // LPCWSTR
        ImageName: *const u16,  // LPCWSTR
        CallBack: *const core::ffi::c_void,  // PFAX_ROUTING_INSTALLATION_CALLBACKW
        Context: *mut ()  // void*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINFAX.dll", SetLastError = true)]
public static extern bool FaxRegisterRoutingExtensionW(IntPtr FaxHandle, [MarshalAs(UnmanagedType.LPWStr)] string ExtensionName, [MarshalAs(UnmanagedType.LPWStr)] string FriendlyName, [MarshalAs(UnmanagedType.LPWStr)] string ImageName, IntPtr CallBack, IntPtr Context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINFAX_FaxRegisterRoutingExtensionW' -Namespace Win32 -PassThru
# $api::FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
#uselib "WINFAX.dll"
#func global FaxRegisterRoutingExtensionW "FaxRegisterRoutingExtensionW" sptr, sptr, sptr, sptr, sptr, sptr
; FaxRegisterRoutingExtensionW FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context   ; 戻り値は stat
; FaxHandle : HANDLE -> "sptr"
; ExtensionName : LPCWSTR -> "sptr"
; FriendlyName : LPCWSTR -> "sptr"
; ImageName : LPCWSTR -> "sptr"
; CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> "sptr"
; Context : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINFAX.dll"
#cfunc global FaxRegisterRoutingExtensionW "FaxRegisterRoutingExtensionW" sptr, wstr, wstr, wstr, sptr, sptr
; res = FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
; FaxHandle : HANDLE -> "sptr"
; ExtensionName : LPCWSTR -> "wstr"
; FriendlyName : LPCWSTR -> "wstr"
; ImageName : LPCWSTR -> "wstr"
; CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> "sptr"
; Context : void* -> "sptr"
; BOOL FaxRegisterRoutingExtensionW(HANDLE FaxHandle, LPCWSTR ExtensionName, LPCWSTR FriendlyName, LPCWSTR ImageName, PFAX_ROUTING_INSTALLATION_CALLBACKW CallBack, void* Context)
#uselib "WINFAX.dll"
#cfunc global FaxRegisterRoutingExtensionW "FaxRegisterRoutingExtensionW" intptr, wstr, wstr, wstr, intptr, intptr
; res = FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
; FaxHandle : HANDLE -> "intptr"
; ExtensionName : LPCWSTR -> "wstr"
; FriendlyName : LPCWSTR -> "wstr"
; ImageName : LPCWSTR -> "wstr"
; CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> "intptr"
; Context : void* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winfax = windows.NewLazySystemDLL("WINFAX.dll")
	procFaxRegisterRoutingExtensionW = winfax.NewProc("FaxRegisterRoutingExtensionW")
)

// FaxHandle (HANDLE), ExtensionName (LPCWSTR), FriendlyName (LPCWSTR), ImageName (LPCWSTR), CallBack (PFAX_ROUTING_INSTALLATION_CALLBACKW), Context (void*)
r1, _, err := procFaxRegisterRoutingExtensionW.Call(
	uintptr(FaxHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ExtensionName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FriendlyName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ImageName))),
	uintptr(CallBack),
	uintptr(Context),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FaxRegisterRoutingExtensionW(
  FaxHandle: THandle;   // HANDLE
  ExtensionName: PWideChar;   // LPCWSTR
  FriendlyName: PWideChar;   // LPCWSTR
  ImageName: PWideChar;   // LPCWSTR
  CallBack: Pointer;   // PFAX_ROUTING_INSTALLATION_CALLBACKW
  Context: Pointer   // void*
): BOOL; stdcall;
  external 'WINFAX.dll' name 'FaxRegisterRoutingExtensionW';
result := DllCall("WINFAX\FaxRegisterRoutingExtensionW"
    , "Ptr", FaxHandle   ; HANDLE
    , "WStr", ExtensionName   ; LPCWSTR
    , "WStr", FriendlyName   ; LPCWSTR
    , "WStr", ImageName   ; LPCWSTR
    , "Ptr", CallBack   ; PFAX_ROUTING_INSTALLATION_CALLBACKW
    , "Ptr", Context   ; void*
    , "Int")   ; return: BOOL
●FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context) = DLL("WINFAX.dll", "bool FaxRegisterRoutingExtensionW(void*, char*, char*, char*, void*, void*)")
# 呼び出し: FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
# FaxHandle : HANDLE -> "void*"
# ExtensionName : LPCWSTR -> "char*"
# FriendlyName : LPCWSTR -> "char*"
# ImageName : LPCWSTR -> "char*"
# CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> "void*"
# Context : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "winfax" fn FaxRegisterRoutingExtensionW(
    FaxHandle: ?*anyopaque, // HANDLE
    ExtensionName: [*c]const u16, // LPCWSTR
    FriendlyName: [*c]const u16, // LPCWSTR
    ImageName: [*c]const u16, // LPCWSTR
    CallBack: ?*anyopaque, // PFAX_ROUTING_INSTALLATION_CALLBACKW
    Context: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) i32;
proc FaxRegisterRoutingExtensionW(
    FaxHandle: pointer,  # HANDLE
    ExtensionName: WideCString,  # LPCWSTR
    FriendlyName: WideCString,  # LPCWSTR
    ImageName: WideCString,  # LPCWSTR
    CallBack: pointer,  # PFAX_ROUTING_INSTALLATION_CALLBACKW
    Context: pointer  # void*
): int32 {.importc: "FaxRegisterRoutingExtensionW", stdcall, dynlib: "WINFAX.dll".}
pragma(lib, "winfax");
extern(Windows)
int FaxRegisterRoutingExtensionW(
    void* FaxHandle,   // HANDLE
    const(wchar)* ExtensionName,   // LPCWSTR
    const(wchar)* FriendlyName,   // LPCWSTR
    const(wchar)* ImageName,   // LPCWSTR
    void* CallBack,   // PFAX_ROUTING_INSTALLATION_CALLBACKW
    void* Context   // void*
);
ccall((:FaxRegisterRoutingExtensionW, "WINFAX.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
      FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
# FaxHandle : HANDLE -> Ptr{Cvoid}
# ExtensionName : LPCWSTR -> Cwstring
# FriendlyName : LPCWSTR -> Cwstring
# ImageName : LPCWSTR -> Cwstring
# CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> Ptr{Cvoid}
# Context : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t FaxRegisterRoutingExtensionW(
    void* FaxHandle,
    const uint16_t* ExtensionName,
    const uint16_t* FriendlyName,
    const uint16_t* ImageName,
    void* CallBack,
    void* Context);
]]
local winfax = ffi.load("winfax")
-- winfax.FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
-- FaxHandle : HANDLE
-- ExtensionName : LPCWSTR
-- FriendlyName : LPCWSTR
-- ImageName : LPCWSTR
-- CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW
-- Context : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WINFAX.dll');
const FaxRegisterRoutingExtensionW = lib.func('__stdcall', 'FaxRegisterRoutingExtensionW', 'int32_t', ['void *', 'str16', 'str16', 'str16', 'void *', 'void *']);
// FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
// FaxHandle : HANDLE -> 'void *'
// ExtensionName : LPCWSTR -> 'str16'
// FriendlyName : LPCWSTR -> 'str16'
// ImageName : LPCWSTR -> 'str16'
// CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> 'void *'
// Context : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("WINFAX.dll", {
  FaxRegisterRoutingExtensionW: { parameters: ["pointer", "buffer", "buffer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context)
// FaxHandle : HANDLE -> "pointer"
// ExtensionName : LPCWSTR -> "buffer"
// FriendlyName : LPCWSTR -> "buffer"
// ImageName : LPCWSTR -> "buffer"
// CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> "pointer"
// Context : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t FaxRegisterRoutingExtensionW(
    void* FaxHandle,
    const uint16_t* ExtensionName,
    const uint16_t* FriendlyName,
    const uint16_t* ImageName,
    void* CallBack,
    void* Context);
C, "WINFAX.dll");
// $ffi->FaxRegisterRoutingExtensionW(FaxHandle, ExtensionName, FriendlyName, ImageName, CallBack, Context);
// FaxHandle : HANDLE
// ExtensionName : LPCWSTR
// FriendlyName : LPCWSTR
// ImageName : LPCWSTR
// CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW
// Context : void*
// 構造体/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 Winfax extends StdCallLibrary {
    Winfax INSTANCE = Native.load("winfax", Winfax.class);
    boolean FaxRegisterRoutingExtensionW(
        Pointer FaxHandle,   // HANDLE
        WString ExtensionName,   // LPCWSTR
        WString FriendlyName,   // LPCWSTR
        WString ImageName,   // LPCWSTR
        Callback CallBack,   // PFAX_ROUTING_INSTALLATION_CALLBACKW
        Pointer Context   // void*
    );
}
@[Link("winfax")]
lib LibWINFAX
  fun FaxRegisterRoutingExtensionW = FaxRegisterRoutingExtensionW(
    FaxHandle : Void*,   # HANDLE
    ExtensionName : UInt16*,   # LPCWSTR
    FriendlyName : UInt16*,   # LPCWSTR
    ImageName : UInt16*,   # LPCWSTR
    CallBack : Void*,   # PFAX_ROUTING_INSTALLATION_CALLBACKW
    Context : Void*   # void*
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef FaxRegisterRoutingExtensionWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef FaxRegisterRoutingExtensionWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final FaxRegisterRoutingExtensionW = DynamicLibrary.open('WINFAX.dll')
    .lookupFunction<FaxRegisterRoutingExtensionWNative, FaxRegisterRoutingExtensionWDart>('FaxRegisterRoutingExtensionW');
// FaxHandle : HANDLE -> Pointer<Void>
// ExtensionName : LPCWSTR -> Pointer<Utf16>
// FriendlyName : LPCWSTR -> Pointer<Utf16>
// ImageName : LPCWSTR -> Pointer<Utf16>
// CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> Pointer<Void>
// Context : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function FaxRegisterRoutingExtensionW(
  FaxHandle: THandle;   // HANDLE
  ExtensionName: PWideChar;   // LPCWSTR
  FriendlyName: PWideChar;   // LPCWSTR
  ImageName: PWideChar;   // LPCWSTR
  CallBack: Pointer;   // PFAX_ROUTING_INSTALLATION_CALLBACKW
  Context: Pointer   // void*
): BOOL; stdcall;
  external 'WINFAX.dll' name 'FaxRegisterRoutingExtensionW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "FaxRegisterRoutingExtensionW"
  c_FaxRegisterRoutingExtensionW :: Ptr () -> CWString -> CWString -> CWString -> Ptr () -> Ptr () -> IO CInt
-- FaxHandle : HANDLE -> Ptr ()
-- ExtensionName : LPCWSTR -> CWString
-- FriendlyName : LPCWSTR -> CWString
-- ImageName : LPCWSTR -> CWString
-- CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> Ptr ()
-- Context : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let faxregisterroutingextensionw =
  foreign "FaxRegisterRoutingExtensionW"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* FaxHandle : HANDLE -> (ptr void) *)
(* ExtensionName : LPCWSTR -> (ptr uint16_t) *)
(* FriendlyName : LPCWSTR -> (ptr uint16_t) *)
(* ImageName : LPCWSTR -> (ptr uint16_t) *)
(* CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> (ptr void) *)
(* Context : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winfax (t "WINFAX.dll"))
(cffi:use-foreign-library winfax)

(cffi:defcfun ("FaxRegisterRoutingExtensionW" fax-register-routing-extension-w :convention :stdcall) :int32
  (fax-handle :pointer)   ; HANDLE
  (extension-name (:string :encoding :utf-16le))   ; LPCWSTR
  (friendly-name (:string :encoding :utf-16le))   ; LPCWSTR
  (image-name (:string :encoding :utf-16le))   ; LPCWSTR
  (call-back :pointer)   ; PFAX_ROUTING_INSTALLATION_CALLBACKW
  (context :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $FaxRegisterRoutingExtensionW = Win32::API::More->new('WINFAX',
    'BOOL FaxRegisterRoutingExtensionW(HANDLE FaxHandle, LPCWSTR ExtensionName, LPCWSTR FriendlyName, LPCWSTR ImageName, LPVOID CallBack, LPVOID Context)');
# my $ret = $FaxRegisterRoutingExtensionW->Call($FaxHandle, $ExtensionName, $FriendlyName, $ImageName, $CallBack, $Context);
# FaxHandle : HANDLE -> HANDLE
# ExtensionName : LPCWSTR -> LPCWSTR
# FriendlyName : LPCWSTR -> LPCWSTR
# ImageName : LPCWSTR -> LPCWSTR
# CallBack : PFAX_ROUTING_INSTALLATION_CALLBACKW -> LPVOID
# Context : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型