Win32 API 日本語リファレンス
ホームNetworking.ActiveDirectory › ADsPropSetHwnd

ADsPropSetHwnd

関数
プロパティページのウィンドウを通知オブジェクトに設定する。
DLLdsprop.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL ADsPropSetHwnd(
    HWND hNotifyObj,
    HWND hPage
);

パラメーター

名前方向説明
hNotifyObjHWNDin通知オブジェクトのウィンドウハンドル。
hPageHWNDin登録するプロパティページのウィンドウハンドル。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ADsPropSetHwnd(
    HWND hNotifyObj,
    HWND hPage
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dsprop.dll", ExactSpelling = true)]
static extern bool ADsPropSetHwnd(
    IntPtr hNotifyObj,   // HWND
    IntPtr hPage   // HWND
);
<DllImport("dsprop.dll", ExactSpelling:=True)>
Public Shared Function ADsPropSetHwnd(
    hNotifyObj As IntPtr,   ' HWND
    hPage As IntPtr   ' HWND
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hNotifyObj : HWND
' hPage : HWND
Declare PtrSafe Function ADsPropSetHwnd Lib "dsprop" ( _
    ByVal hNotifyObj As LongPtr, _
    ByVal hPage As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ADsPropSetHwnd = ctypes.windll.dsprop.ADsPropSetHwnd
ADsPropSetHwnd.restype = wintypes.BOOL
ADsPropSetHwnd.argtypes = [
    wintypes.HANDLE,  # hNotifyObj : HWND
    wintypes.HANDLE,  # hPage : HWND
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dsprop.dll')
ADsPropSetHwnd = Fiddle::Function.new(
  lib['ADsPropSetHwnd'],
  [
    Fiddle::TYPE_VOIDP,  # hNotifyObj : HWND
    Fiddle::TYPE_VOIDP,  # hPage : HWND
  ],
  Fiddle::TYPE_INT)
#[link(name = "dsprop")]
extern "system" {
    fn ADsPropSetHwnd(
        hNotifyObj: *mut core::ffi::c_void,  // HWND
        hPage: *mut core::ffi::c_void  // HWND
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dsprop.dll")]
public static extern bool ADsPropSetHwnd(IntPtr hNotifyObj, IntPtr hPage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dsprop_ADsPropSetHwnd' -Namespace Win32 -PassThru
# $api::ADsPropSetHwnd(hNotifyObj, hPage)
#uselib "dsprop.dll"
#func global ADsPropSetHwnd "ADsPropSetHwnd" sptr, sptr
; ADsPropSetHwnd hNotifyObj, hPage   ; 戻り値は stat
; hNotifyObj : HWND -> "sptr"
; hPage : HWND -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dsprop.dll"
#cfunc global ADsPropSetHwnd "ADsPropSetHwnd" sptr, sptr
; res = ADsPropSetHwnd(hNotifyObj, hPage)
; hNotifyObj : HWND -> "sptr"
; hPage : HWND -> "sptr"
; BOOL ADsPropSetHwnd(HWND hNotifyObj, HWND hPage)
#uselib "dsprop.dll"
#cfunc global ADsPropSetHwnd "ADsPropSetHwnd" intptr, intptr
; res = ADsPropSetHwnd(hNotifyObj, hPage)
; hNotifyObj : HWND -> "intptr"
; hPage : HWND -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dsprop = windows.NewLazySystemDLL("dsprop.dll")
	procADsPropSetHwnd = dsprop.NewProc("ADsPropSetHwnd")
)

// hNotifyObj (HWND), hPage (HWND)
r1, _, err := procADsPropSetHwnd.Call(
	uintptr(hNotifyObj),
	uintptr(hPage),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ADsPropSetHwnd(
  hNotifyObj: THandle;   // HWND
  hPage: THandle   // HWND
): BOOL; stdcall;
  external 'dsprop.dll' name 'ADsPropSetHwnd';
result := DllCall("dsprop\ADsPropSetHwnd"
    , "Ptr", hNotifyObj   ; HWND
    , "Ptr", hPage   ; HWND
    , "Int")   ; return: BOOL
●ADsPropSetHwnd(hNotifyObj, hPage) = DLL("dsprop.dll", "bool ADsPropSetHwnd(void*, void*)")
# 呼び出し: ADsPropSetHwnd(hNotifyObj, hPage)
# hNotifyObj : HWND -> "void*"
# hPage : HWND -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef ADsPropSetHwndNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef ADsPropSetHwndDart = int Function(Pointer<Void>, Pointer<Void>);
final ADsPropSetHwnd = DynamicLibrary.open('dsprop.dll')
    .lookupFunction<ADsPropSetHwndNative, ADsPropSetHwndDart>('ADsPropSetHwnd');
// hNotifyObj : HWND -> Pointer<Void>
// hPage : HWND -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ADsPropSetHwnd(
  hNotifyObj: THandle;   // HWND
  hPage: THandle   // HWND
): BOOL; stdcall;
  external 'dsprop.dll' name 'ADsPropSetHwnd';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ADsPropSetHwnd"
  c_ADsPropSetHwnd :: Ptr () -> Ptr () -> IO CInt
-- hNotifyObj : HWND -> Ptr ()
-- hPage : HWND -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let adspropsethwnd =
  foreign "ADsPropSetHwnd"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* hNotifyObj : HWND -> (ptr void) *)
(* hPage : HWND -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dsprop (t "dsprop.dll"))
(cffi:use-foreign-library dsprop)

(cffi:defcfun ("ADsPropSetHwnd" ads-prop-set-hwnd :convention :stdcall) :int32
  (h-notify-obj :pointer)   ; HWND
  (h-page :pointer))   ; HWND
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ADsPropSetHwnd = Win32::API::More->new('dsprop',
    'BOOL ADsPropSetHwnd(HANDLE hNotifyObj, HANDLE hPage)');
# my $ret = $ADsPropSetHwnd->Call($hNotifyObj, $hPage);
# hNotifyObj : HWND -> HANDLE
# hPage : HWND -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。