ホーム › System.DataExchange › UnpackDDElParam
UnpackDDElParam
関数DDEメッセージのlParamを2つの値に展開する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL UnpackDDElParam(
DWORD msg,
LPARAM lParam,
UINT_PTR* puiLo,
UINT_PTR* puiHi
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| msg | DWORD | in | ポストされた DDE メッセージです。 |
| lParam | LPARAM | in | 受け取った、ポストされた DDE メッセージの lParam パラメーターです。アプリケーションは FreeDDElParam 関数を呼び出して、 lParam パラメーターで指定されたメモリオブジェクトを解放する必要があります。 |
| puiLo | UINT_PTR* | out | |
| puiHi | UINT_PTR* | out | |
戻り値の型: BOOL
公式ドキュメント
ポストされた DDE メッセージから受け取った動的データ交換 (Dynamic Data Exchange, DDE) の lParam 値を展開します。
戻り値
型: BOOL
関数が成功した場合、戻り値は 0 以外の値になります。
関数が失敗した場合、戻り値は 0 になります。
解説(Remarks)
PackDDElParam は、16 ビット DDE アプリケーションを 32 ビット DDE アプリケーションへ移植する作業を容易にします。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL UnpackDDElParam(
DWORD msg,
LPARAM lParam,
UINT_PTR* puiLo,
UINT_PTR* puiHi
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool UnpackDDElParam(
uint msg, // DWORD
IntPtr lParam, // LPARAM
out UIntPtr puiLo, // UINT_PTR* out
out UIntPtr puiHi // UINT_PTR* out
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function UnpackDDElParam(
msg As UInteger, ' DWORD
lParam As IntPtr, ' LPARAM
<Out> ByRef puiLo As UIntPtr, ' UINT_PTR* out
<Out> ByRef puiHi As UIntPtr ' UINT_PTR* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' msg : DWORD
' lParam : LPARAM
' puiLo : UINT_PTR* out
' puiHi : UINT_PTR* out
Declare PtrSafe Function UnpackDDElParam Lib "user32" ( _
ByVal msg As Long, _
ByVal lParam As LongPtr, _
ByRef puiLo As LongPtr, _
ByRef puiHi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UnpackDDElParam = ctypes.windll.user32.UnpackDDElParam
UnpackDDElParam.restype = wintypes.BOOL
UnpackDDElParam.argtypes = [
wintypes.DWORD, # msg : DWORD
ctypes.c_ssize_t, # lParam : LPARAM
ctypes.POINTER(ctypes.c_size_t), # puiLo : UINT_PTR* out
ctypes.POINTER(ctypes.c_size_t), # puiHi : UINT_PTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
UnpackDDElParam = Fiddle::Function.new(
lib['UnpackDDElParam'],
[
-Fiddle::TYPE_INT, # msg : DWORD
Fiddle::TYPE_INTPTR_T, # lParam : LPARAM
Fiddle::TYPE_VOIDP, # puiLo : UINT_PTR* out
Fiddle::TYPE_VOIDP, # puiHi : UINT_PTR* out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn UnpackDDElParam(
msg: u32, // DWORD
lParam: isize, // LPARAM
puiLo: *mut usize, // UINT_PTR* out
puiHi: *mut usize // UINT_PTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool UnpackDDElParam(uint msg, IntPtr lParam, out UIntPtr puiLo, out UIntPtr puiHi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_UnpackDDElParam' -Namespace Win32 -PassThru
# $api::UnpackDDElParam(msg, lParam, puiLo, puiHi)#uselib "USER32.dll"
#func global UnpackDDElParam "UnpackDDElParam" sptr, sptr, sptr, sptr
; UnpackDDElParam msg, lParam, varptr(puiLo), varptr(puiHi) ; 戻り値は stat
; msg : DWORD -> "sptr"
; lParam : LPARAM -> "sptr"
; puiLo : UINT_PTR* out -> "sptr"
; puiHi : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global UnpackDDElParam "UnpackDDElParam" int, sptr, var, var ; res = UnpackDDElParam(msg, lParam, puiLo, puiHi) ; msg : DWORD -> "int" ; lParam : LPARAM -> "sptr" ; puiLo : UINT_PTR* out -> "var" ; puiHi : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global UnpackDDElParam "UnpackDDElParam" int, sptr, sptr, sptr ; res = UnpackDDElParam(msg, lParam, varptr(puiLo), varptr(puiHi)) ; msg : DWORD -> "int" ; lParam : LPARAM -> "sptr" ; puiLo : UINT_PTR* out -> "sptr" ; puiHi : UINT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL UnpackDDElParam(DWORD msg, LPARAM lParam, UINT_PTR* puiLo, UINT_PTR* puiHi) #uselib "USER32.dll" #cfunc global UnpackDDElParam "UnpackDDElParam" int, intptr, var, var ; res = UnpackDDElParam(msg, lParam, puiLo, puiHi) ; msg : DWORD -> "int" ; lParam : LPARAM -> "intptr" ; puiLo : UINT_PTR* out -> "var" ; puiHi : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL UnpackDDElParam(DWORD msg, LPARAM lParam, UINT_PTR* puiLo, UINT_PTR* puiHi) #uselib "USER32.dll" #cfunc global UnpackDDElParam "UnpackDDElParam" int, intptr, intptr, intptr ; res = UnpackDDElParam(msg, lParam, varptr(puiLo), varptr(puiHi)) ; msg : DWORD -> "int" ; lParam : LPARAM -> "intptr" ; puiLo : UINT_PTR* out -> "intptr" ; puiHi : UINT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procUnpackDDElParam = user32.NewProc("UnpackDDElParam")
)
// msg (DWORD), lParam (LPARAM), puiLo (UINT_PTR* out), puiHi (UINT_PTR* out)
r1, _, err := procUnpackDDElParam.Call(
uintptr(msg),
uintptr(lParam),
uintptr(puiLo),
uintptr(puiHi),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction UnpackDDElParam(
msg: DWORD; // DWORD
lParam: NativeInt; // LPARAM
puiLo: Pointer; // UINT_PTR* out
puiHi: Pointer // UINT_PTR* out
): BOOL; stdcall;
external 'USER32.dll' name 'UnpackDDElParam';result := DllCall("USER32\UnpackDDElParam"
, "UInt", msg ; DWORD
, "Ptr", lParam ; LPARAM
, "Ptr", puiLo ; UINT_PTR* out
, "Ptr", puiHi ; UINT_PTR* out
, "Int") ; return: BOOL●UnpackDDElParam(msg, lParam, puiLo, puiHi) = DLL("USER32.dll", "bool UnpackDDElParam(dword, int, void*, void*)")
# 呼び出し: UnpackDDElParam(msg, lParam, puiLo, puiHi)
# msg : DWORD -> "dword"
# lParam : LPARAM -> "int"
# puiLo : UINT_PTR* out -> "void*"
# puiHi : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn UnpackDDElParam(
msg: u32, // DWORD
lParam: isize, // LPARAM
puiLo: [*c]usize, // UINT_PTR* out
puiHi: [*c]usize // UINT_PTR* out
) callconv(std.os.windows.WINAPI) i32;proc UnpackDDElParam(
msg: uint32, # DWORD
lParam: int, # LPARAM
puiLo: ptr uint, # UINT_PTR* out
puiHi: ptr uint # UINT_PTR* out
): int32 {.importc: "UnpackDDElParam", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int UnpackDDElParam(
uint msg, // DWORD
ptrdiff_t lParam, // LPARAM
size_t* puiLo, // UINT_PTR* out
size_t* puiHi // UINT_PTR* out
);ccall((:UnpackDDElParam, "USER32.dll"), stdcall, Int32,
(UInt32, Int, Ptr{Csize_t}, Ptr{Csize_t}),
msg, lParam, puiLo, puiHi)
# msg : DWORD -> UInt32
# lParam : LPARAM -> Int
# puiLo : UINT_PTR* out -> Ptr{Csize_t}
# puiHi : UINT_PTR* out -> Ptr{Csize_t}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t UnpackDDElParam(
uint32_t msg,
intptr_t lParam,
uintptr_t* puiLo,
uintptr_t* puiHi);
]]
local user32 = ffi.load("user32")
-- user32.UnpackDDElParam(msg, lParam, puiLo, puiHi)
-- msg : DWORD
-- lParam : LPARAM
-- puiLo : UINT_PTR* out
-- puiHi : UINT_PTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const UnpackDDElParam = lib.func('__stdcall', 'UnpackDDElParam', 'int32_t', ['uint32_t', 'intptr_t', 'uintptr_t *', 'uintptr_t *']);
// UnpackDDElParam(msg, lParam, puiLo, puiHi)
// msg : DWORD -> 'uint32_t'
// lParam : LPARAM -> 'intptr_t'
// puiLo : UINT_PTR* out -> 'uintptr_t *'
// puiHi : UINT_PTR* out -> 'uintptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
UnpackDDElParam: { parameters: ["u32", "isize", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.UnpackDDElParam(msg, lParam, puiLo, puiHi)
// msg : DWORD -> "u32"
// lParam : LPARAM -> "isize"
// puiLo : UINT_PTR* out -> "pointer"
// puiHi : UINT_PTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UnpackDDElParam(
uint32_t msg,
intptr_t lParam,
size_t* puiLo,
size_t* puiHi);
C, "USER32.dll");
// $ffi->UnpackDDElParam(msg, lParam, puiLo, puiHi);
// msg : DWORD
// lParam : LPARAM
// puiLo : UINT_PTR* out
// puiHi : UINT_PTR* 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 User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
boolean UnpackDDElParam(
int msg, // DWORD
long lParam, // LPARAM
LongByReference puiLo, // UINT_PTR* out
LongByReference puiHi // UINT_PTR* out
);
}@[Link("user32")]
lib LibUSER32
fun UnpackDDElParam = UnpackDDElParam(
msg : UInt32, # DWORD
lParam : LibC::SSizeT, # LPARAM
puiLo : LibC::SizeT*, # UINT_PTR* out
puiHi : LibC::SizeT* # UINT_PTR* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UnpackDDElParamNative = Int32 Function(Uint32, IntPtr, Pointer<UintPtr>, Pointer<UintPtr>);
typedef UnpackDDElParamDart = int Function(int, int, Pointer<UintPtr>, Pointer<UintPtr>);
final UnpackDDElParam = DynamicLibrary.open('USER32.dll')
.lookupFunction<UnpackDDElParamNative, UnpackDDElParamDart>('UnpackDDElParam');
// msg : DWORD -> Uint32
// lParam : LPARAM -> IntPtr
// puiLo : UINT_PTR* out -> Pointer<UintPtr>
// puiHi : UINT_PTR* out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UnpackDDElParam(
msg: DWORD; // DWORD
lParam: NativeInt; // LPARAM
puiLo: Pointer; // UINT_PTR* out
puiHi: Pointer // UINT_PTR* out
): BOOL; stdcall;
external 'USER32.dll' name 'UnpackDDElParam';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UnpackDDElParam"
c_UnpackDDElParam :: Word32 -> CIntPtr -> Ptr CUIntPtr -> Ptr CUIntPtr -> IO CInt
-- msg : DWORD -> Word32
-- lParam : LPARAM -> CIntPtr
-- puiLo : UINT_PTR* out -> Ptr CUIntPtr
-- puiHi : UINT_PTR* out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let unpackddelparam =
foreign "UnpackDDElParam"
(uint32_t @-> intptr_t @-> (ptr size_t) @-> (ptr size_t) @-> returning int32_t)
(* msg : DWORD -> uint32_t *)
(* lParam : LPARAM -> intptr_t *)
(* puiLo : UINT_PTR* out -> (ptr size_t) *)
(* puiHi : UINT_PTR* out -> (ptr size_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("UnpackDDElParam" unpack-ddel-param :convention :stdcall) :int32
(msg :uint32) ; DWORD
(l-param :int64) ; LPARAM
(pui-lo :pointer) ; UINT_PTR* out
(pui-hi :pointer)) ; UINT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UnpackDDElParam = Win32::API::More->new('USER32',
'BOOL UnpackDDElParam(DWORD msg, LPARAM lParam, LPVOID puiLo, LPVOID puiHi)');
# my $ret = $UnpackDDElParam->Call($msg, $lParam, $puiLo, $puiHi);
# msg : DWORD -> DWORD
# lParam : LPARAM -> LPARAM
# puiLo : UINT_PTR* out -> LPVOID
# puiHi : UINT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f FreeDDElParam — PackDDElParamで確保したlParamのメモリを解放する。
- f PackDDElParam — DDEメッセージの2つの値を単一のlParamにパックする。
- f ReuseDDElParam — DDEメッセージのlParamを再利用して別メッセージ用に再構成する。