ホーム › System.WindowsProgramming › DCICreatePrimary
DCICreatePrimary
関数プライマリ表示サーフェスを作成する。
シグネチャ
// DCIMAN32.dll
#include <windows.h>
INT DCICreatePrimary(
HDC hdc,
DCISURFACEINFO** lplpSurface
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | プライマリサーフェスを作成する対象のデバイスコンテキストハンドル。 |
| lplpSurface | DCISURFACEINFO** | inout | 作成されたプライマリサーフェス情報(DCISURFACEINFO)へのポインタを受け取る変数のアドレス。 |
戻り値の型: 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 方式にも切替可。#uselib "DCIMAN32.dll" #cfunc global DCICreatePrimary "DCICreatePrimary" sptr, sptr ; res = DCICreatePrimary(hdc, varptr(lplpSurface)) ; hdc : HDC -> "sptr" ; lplpSurface : DCISURFACEINFO** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; INT DCICreatePrimary(HDC hdc, DCISURFACEINFO** lplpSurface) #uselib "DCIMAN32.dll" #cfunc global DCICreatePrimary "DCICreatePrimary" intptr, intptr ; res = DCICreatePrimary(hdc, varptr(lplpSurface)) ; hdc : HDC -> "intptr" ; lplpSurface : DCISURFACEINFO** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // INTfunction 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)。const std = @import("std");
extern "dciman32" fn DCICreatePrimary(
hdc: ?*anyopaque, // HDC
lplpSurface: [*c][*c]DCISURFACEINFO // DCISURFACEINFO** in/out
) callconv(std.os.windows.WINAPI) i32;proc DCICreatePrimary(
hdc: pointer, # HDC
lplpSurface: ptr DCISURFACEINFO # DCISURFACEINFO** in/out
): int32 {.importc: "DCICreatePrimary", stdcall, dynlib: "DCIMAN32.dll".}pragma(lib, "dciman32");
extern(Windows)
int DCICreatePrimary(
void* hdc, // HDC
DCISURFACEINFO** lplpSurface // DCISURFACEINFO** in/out
);ccall((:DCICreatePrimary, "DCIMAN32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{DCISURFACEINFO}),
hdc, lplpSurface)
# hdc : HDC -> Ptr{Cvoid}
# lplpSurface : DCISURFACEINFO** in/out -> Ptr{DCISURFACEINFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DCICreatePrimary(
void* hdc,
void* lplpSurface);
]]
local dciman32 = ffi.load("dciman32")
-- dciman32.DCICreatePrimary(hdc, lplpSurface)
-- hdc : HDC
-- lplpSurface : DCISURFACEINFO** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DCIMAN32.dll');
const DCICreatePrimary = lib.func('__stdcall', 'DCICreatePrimary', 'int32_t', ['void *', 'void *']);
// DCICreatePrimary(hdc, lplpSurface)
// hdc : HDC -> 'void *'
// lplpSurface : DCISURFACEINFO** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DCIMAN32.dll", {
DCICreatePrimary: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.DCICreatePrimary(hdc, lplpSurface)
// hdc : HDC -> "pointer"
// lplpSurface : DCISURFACEINFO** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DCICreatePrimary(
void* hdc,
void* lplpSurface);
C, "DCIMAN32.dll");
// $ffi->DCICreatePrimary(hdc, lplpSurface);
// hdc : HDC
// lplpSurface : DCISURFACEINFO** 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 Dciman32 extends StdCallLibrary {
Dciman32 INSTANCE = Native.load("dciman32", Dciman32.class);
int DCICreatePrimary(
Pointer hdc, // HDC
Pointer lplpSurface // DCISURFACEINFO** in/out
);
}@[Link("dciman32")]
lib LibDCIMAN32
fun DCICreatePrimary = DCICreatePrimary(
hdc : Void*, # HDC
lplpSurface : DCISURFACEINFO** # DCISURFACEINFO** 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 DCICreatePrimaryNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef DCICreatePrimaryDart = int Function(Pointer<Void>, Pointer<Void>);
final DCICreatePrimary = DynamicLibrary.open('DCIMAN32.dll')
.lookupFunction<DCICreatePrimaryNative, DCICreatePrimaryDart>('DCICreatePrimary');
// hdc : HDC -> Pointer<Void>
// lplpSurface : DCISURFACEINFO** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DCICreatePrimary(
hdc: THandle; // HDC
lplpSurface: Pointer // DCISURFACEINFO** in/out
): Integer; stdcall;
external 'DCIMAN32.dll' name 'DCICreatePrimary';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DCICreatePrimary"
c_DCICreatePrimary :: Ptr () -> Ptr () -> IO Int32
-- hdc : HDC -> Ptr ()
-- lplpSurface : DCISURFACEINFO** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dcicreateprimary =
foreign "DCICreatePrimary"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* lplpSurface : DCISURFACEINFO** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dciman32 (t "DCIMAN32.dll"))
(cffi:use-foreign-library dciman32)
(cffi:defcfun ("DCICreatePrimary" dcicreate-primary :convention :stdcall) :int32
(hdc :pointer) ; HDC
(lplp-surface :pointer)) ; DCISURFACEINFO** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DCICreatePrimary = Win32::API::More->new('DCIMAN32',
'int DCICreatePrimary(HANDLE hdc, LPVOID lplpSurface)');
# my $ret = $DCICreatePrimary->Call($hdc, $lplpSurface);
# hdc : HDC -> HANDLE
# lplpSurface : DCISURFACEINFO** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型