ホーム › Graphics.Printing › GdiGetDevmodeForPage
GdiGetDevmodeForPage
関数指定ページに適用されるDEVMODEを取得する。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL GdiGetDevmodeForPage(
HANDLE SpoolFileHandle,
DWORD dwPageNumber,
DEVMODEW** pCurrDM,
DEVMODEW** pLastDM
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| SpoolFileHandle | HANDLE | in |
| dwPageNumber | DWORD | in |
| pCurrDM | DEVMODEW** | inout |
| pLastDM | DEVMODEW** | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL GdiGetDevmodeForPage(
HANDLE SpoolFileHandle,
DWORD dwPageNumber,
DEVMODEW** pCurrDM,
DEVMODEW** pLastDM
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool GdiGetDevmodeForPage(
IntPtr SpoolFileHandle, // HANDLE
uint dwPageNumber, // DWORD
IntPtr pCurrDM, // DEVMODEW** in/out
IntPtr pLastDM // DEVMODEW** in/out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GdiGetDevmodeForPage(
SpoolFileHandle As IntPtr, ' HANDLE
dwPageNumber As UInteger, ' DWORD
pCurrDM As IntPtr, ' DEVMODEW** in/out
pLastDM As IntPtr ' DEVMODEW** in/out
) As Boolean
End Function' SpoolFileHandle : HANDLE
' dwPageNumber : DWORD
' pCurrDM : DEVMODEW** in/out
' pLastDM : DEVMODEW** in/out
Declare PtrSafe Function GdiGetDevmodeForPage Lib "gdi32" ( _
ByVal SpoolFileHandle As LongPtr, _
ByVal dwPageNumber As Long, _
ByVal pCurrDM As LongPtr, _
ByVal pLastDM As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdiGetDevmodeForPage = ctypes.windll.gdi32.GdiGetDevmodeForPage
GdiGetDevmodeForPage.restype = wintypes.BOOL
GdiGetDevmodeForPage.argtypes = [
wintypes.HANDLE, # SpoolFileHandle : HANDLE
wintypes.DWORD, # dwPageNumber : DWORD
ctypes.c_void_p, # pCurrDM : DEVMODEW** in/out
ctypes.c_void_p, # pLastDM : DEVMODEW** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GdiGetDevmodeForPage = Fiddle::Function.new(
lib['GdiGetDevmodeForPage'],
[
Fiddle::TYPE_VOIDP, # SpoolFileHandle : HANDLE
-Fiddle::TYPE_INT, # dwPageNumber : DWORD
Fiddle::TYPE_VOIDP, # pCurrDM : DEVMODEW** in/out
Fiddle::TYPE_VOIDP, # pLastDM : DEVMODEW** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn GdiGetDevmodeForPage(
SpoolFileHandle: *mut core::ffi::c_void, // HANDLE
dwPageNumber: u32, // DWORD
pCurrDM: *mut *mut DEVMODEW, // DEVMODEW** in/out
pLastDM: *mut *mut DEVMODEW // DEVMODEW** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool GdiGetDevmodeForPage(IntPtr SpoolFileHandle, uint dwPageNumber, IntPtr pCurrDM, IntPtr pLastDM);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GdiGetDevmodeForPage' -Namespace Win32 -PassThru
# $api::GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, pCurrDM, pLastDM)#uselib "GDI32.dll"
#func global GdiGetDevmodeForPage "GdiGetDevmodeForPage" sptr, sptr, sptr, sptr
; GdiGetDevmodeForPage SpoolFileHandle, dwPageNumber, varptr(pCurrDM), varptr(pLastDM) ; 戻り値は stat
; SpoolFileHandle : HANDLE -> "sptr"
; dwPageNumber : DWORD -> "sptr"
; pCurrDM : DEVMODEW** in/out -> "sptr"
; pLastDM : DEVMODEW** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global GdiGetDevmodeForPage "GdiGetDevmodeForPage" sptr, int, var, var ; res = GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, pCurrDM, pLastDM) ; SpoolFileHandle : HANDLE -> "sptr" ; dwPageNumber : DWORD -> "int" ; pCurrDM : DEVMODEW** in/out -> "var" ; pLastDM : DEVMODEW** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global GdiGetDevmodeForPage "GdiGetDevmodeForPage" sptr, int, sptr, sptr ; res = GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, varptr(pCurrDM), varptr(pLastDM)) ; SpoolFileHandle : HANDLE -> "sptr" ; dwPageNumber : DWORD -> "int" ; pCurrDM : DEVMODEW** in/out -> "sptr" ; pLastDM : DEVMODEW** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GdiGetDevmodeForPage(HANDLE SpoolFileHandle, DWORD dwPageNumber, DEVMODEW** pCurrDM, DEVMODEW** pLastDM) #uselib "GDI32.dll" #cfunc global GdiGetDevmodeForPage "GdiGetDevmodeForPage" intptr, int, var, var ; res = GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, pCurrDM, pLastDM) ; SpoolFileHandle : HANDLE -> "intptr" ; dwPageNumber : DWORD -> "int" ; pCurrDM : DEVMODEW** in/out -> "var" ; pLastDM : DEVMODEW** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GdiGetDevmodeForPage(HANDLE SpoolFileHandle, DWORD dwPageNumber, DEVMODEW** pCurrDM, DEVMODEW** pLastDM) #uselib "GDI32.dll" #cfunc global GdiGetDevmodeForPage "GdiGetDevmodeForPage" intptr, int, intptr, intptr ; res = GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, varptr(pCurrDM), varptr(pLastDM)) ; SpoolFileHandle : HANDLE -> "intptr" ; dwPageNumber : DWORD -> "int" ; pCurrDM : DEVMODEW** in/out -> "intptr" ; pLastDM : DEVMODEW** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGdiGetDevmodeForPage = gdi32.NewProc("GdiGetDevmodeForPage")
)
// SpoolFileHandle (HANDLE), dwPageNumber (DWORD), pCurrDM (DEVMODEW** in/out), pLastDM (DEVMODEW** in/out)
r1, _, err := procGdiGetDevmodeForPage.Call(
uintptr(SpoolFileHandle),
uintptr(dwPageNumber),
uintptr(pCurrDM),
uintptr(pLastDM),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GdiGetDevmodeForPage(
SpoolFileHandle: THandle; // HANDLE
dwPageNumber: DWORD; // DWORD
pCurrDM: Pointer; // DEVMODEW** in/out
pLastDM: Pointer // DEVMODEW** in/out
): BOOL; stdcall;
external 'GDI32.dll' name 'GdiGetDevmodeForPage';result := DllCall("GDI32\GdiGetDevmodeForPage"
, "Ptr", SpoolFileHandle ; HANDLE
, "UInt", dwPageNumber ; DWORD
, "Ptr", pCurrDM ; DEVMODEW** in/out
, "Ptr", pLastDM ; DEVMODEW** in/out
, "Int") ; return: BOOL●GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, pCurrDM, pLastDM) = DLL("GDI32.dll", "bool GdiGetDevmodeForPage(void*, dword, void*, void*)")
# 呼び出し: GdiGetDevmodeForPage(SpoolFileHandle, dwPageNumber, pCurrDM, pLastDM)
# SpoolFileHandle : HANDLE -> "void*"
# dwPageNumber : DWORD -> "dword"
# pCurrDM : DEVMODEW** in/out -> "void*"
# pLastDM : DEVMODEW** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。