Win32 API 日本語リファレンス
ホームSystem.WindowsProgramming › DCICreatePrimary

DCICreatePrimary

関数
プライマリ表示サーフェスを作成する。
DLLDCIMAN32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT DCICreatePrimary(
    HDC hdc,
    DCISURFACEINFO** lplpSurface
);

パラメーター

名前方向
hdcHDCin
lplpSurfaceDCISURFACEINFO**inout

戻り値の型: INT

各言語での呼び出し定義

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

INT DCICreatePrimary(
    HDC hdc,
    DCISURFACEINFO** lplpSurface
);
[DllImport("DCIMAN32.dll", ExactSpelling = true)]
static extern int DCICreatePrimary(
    IntPtr hdc,   // HDC
    IntPtr lplpSurface   // DCISURFACEINFO** in/out
);
<DllImport("DCIMAN32.dll", ExactSpelling:=True)>
Public Shared Function DCICreatePrimary(
    hdc As IntPtr,   ' HDC
    lplpSurface As IntPtr   ' DCISURFACEINFO** in/out
) As Integer
End Function
' hdc : HDC
' lplpSurface : DCISURFACEINFO** in/out
Declare PtrSafe Function DCICreatePrimary Lib "dciman32" ( _
    ByVal hdc As LongPtr, _
    ByVal lplpSurface As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DCICreatePrimary = ctypes.windll.dciman32.DCICreatePrimary
DCICreatePrimary.restype = ctypes.c_int
DCICreatePrimary.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_void_p,  # lplpSurface : DCISURFACEINFO** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DCIMAN32.dll')
DCICreatePrimary = Fiddle::Function.new(
  lib['DCICreatePrimary'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # lplpSurface : DCISURFACEINFO** in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "dciman32")]
extern "system" {
    fn DCICreatePrimary(
        hdc: *mut core::ffi::c_void,  // HDC
        lplpSurface: *mut *mut DCISURFACEINFO  // DCISURFACEINFO** in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DCIMAN32.dll")]
public static extern int DCICreatePrimary(IntPtr hdc, IntPtr lplpSurface);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DCIMAN32_DCICreatePrimary' -Namespace Win32 -PassThru
# $api::DCICreatePrimary(hdc, lplpSurface)
#uselib "DCIMAN32.dll"
#func global DCICreatePrimary "DCICreatePrimary" sptr, sptr
; DCICreatePrimary hdc, varptr(lplpSurface)   ; 戻り値は stat
; hdc : HDC -> "sptr"
; lplpSurface : DCISURFACEINFO** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DCIMAN32.dll"
#cfunc global DCICreatePrimary "DCICreatePrimary" sptr, var
; res = DCICreatePrimary(hdc, lplpSurface)
; hdc : HDC -> "sptr"
; lplpSurface : DCISURFACEINFO** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT DCICreatePrimary(HDC hdc, DCISURFACEINFO** lplpSurface)
#uselib "DCIMAN32.dll"
#cfunc global DCICreatePrimary "DCICreatePrimary" intptr, var
; res = DCICreatePrimary(hdc, lplpSurface)
; hdc : HDC -> "intptr"
; lplpSurface : DCISURFACEINFO** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
	procDCICreatePrimary = dciman32.NewProc("DCICreatePrimary")
)

// hdc (HDC), lplpSurface (DCISURFACEINFO** in/out)
r1, _, err := procDCICreatePrimary.Call(
	uintptr(hdc),
	uintptr(lplpSurface),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DCICreatePrimary(
  hdc: THandle;   // HDC
  lplpSurface: Pointer   // DCISURFACEINFO** in/out
): Integer; stdcall;
  external 'DCIMAN32.dll' name 'DCICreatePrimary';
result := DllCall("DCIMAN32\DCICreatePrimary"
    , "Ptr", hdc   ; HDC
    , "Ptr", lplpSurface   ; DCISURFACEINFO** in/out
    , "Int")   ; return: INT
●DCICreatePrimary(hdc, lplpSurface) = DLL("DCIMAN32.dll", "int DCICreatePrimary(void*, void*)")
# 呼び出し: DCICreatePrimary(hdc, lplpSurface)
# hdc : HDC -> "void*"
# lplpSurface : DCISURFACEINFO** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。