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

CONVCONTEXT

構造体
サイズx64: 36 バイト / x86: 36 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
cbDWORD4+0+0この構造体のサイズ (バイト単位)。
wFlagsDWORD4+4+4会話コンテキストのフラグ。現在、このメンバーに対して定義されているフラグはありません。
wCountryIDDWORD4+8+8トピック名および項目名の文字列に使用する国/地域コード識別子。
iCodePageINT4+12+12トピック名および項目名の文字列に使用するコードページ。多言語対応ではないクライアントは、このメンバーに CP_WINANSI を設定してください。Unicode クライアントは、この値に CP_WINUNICODE を設定してください。
dwLangIDDWORD4+16+16トピック名および項目名の文字列に使用する言語識別子
dwSecurityDWORD4+20+20プライベートな (アプリケーション定義の) セキュリティコード。
qosSECURITY_QUALITY_OF_SERVICE12+24+24DDE クライアントが、特定の会話中にシステムに対して要求するサービスの品質。指定されたサービス品質のレベルは、その会話が続く間有効です。会話の開始後に変更することはできません。

公式ドキュメント

動的データ交換 (DDE) クライアントアプリケーションが提供する情報を格納します。この情報は、特殊な DDE 会話や言語をまたぐ DDE 会話で役立ちます。

解説(Remarks)

セキュリティに関する警告

セキュリティを高めるために、アプリケーションは dwSecurity メンバーでセキュリティコードを指定できます。アプリケーションは DdeCallback 関数でこの値を調べ、クライアントアプリケーションの身元を確認できます。ただし、アプリケーションにハードコードされた値は発見されるおそれがあります。そのため、ユーザーの入力を通じて受け取るなど、別の方法でセキュリティコードを与えることを検討してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// SECURITY_QUALITY_OF_SERVICE  (x64 12 / x86 12 バイト)
typedef struct SECURITY_QUALITY_OF_SERVICE {
    DWORD Length;
    SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
    BYTE ContextTrackingMode;
    BOOLEAN EffectiveOnly;
} SECURITY_QUALITY_OF_SERVICE;

// CONVCONTEXT  (x64 36 / x86 36 バイト)
typedef struct CONVCONTEXT {
    DWORD cb;
    DWORD wFlags;
    DWORD wCountryID;
    INT iCodePage;
    DWORD dwLangID;
    DWORD dwSecurity;
    SECURITY_QUALITY_OF_SERVICE qos;
} CONVCONTEXT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SECURITY_QUALITY_OF_SERVICE
{
    public uint Length;
    public int ImpersonationLevel;
    public byte ContextTrackingMode;
    [MarshalAs(UnmanagedType.U1)] public bool EffectiveOnly;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONVCONTEXT
{
    public uint cb;
    public uint wFlags;
    public uint wCountryID;
    public int iCodePage;
    public uint dwLangID;
    public uint dwSecurity;
    public SECURITY_QUALITY_OF_SERVICE qos;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SECURITY_QUALITY_OF_SERVICE
    Public Length As UInteger
    Public ImpersonationLevel As Integer
    Public ContextTrackingMode As Byte
    <MarshalAs(UnmanagedType.U1)> Public EffectiveOnly As Boolean
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONVCONTEXT
    Public cb As UInteger
    Public wFlags As UInteger
    Public wCountryID As UInteger
    Public iCodePage As Integer
    Public dwLangID As UInteger
    Public dwSecurity As UInteger
    Public qos As SECURITY_QUALITY_OF_SERVICE
End Structure
import ctypes
from ctypes import wintypes

class SECURITY_QUALITY_OF_SERVICE(ctypes.Structure):
    _fields_ = [
        ("Length", wintypes.DWORD),
        ("ImpersonationLevel", ctypes.c_int),
        ("ContextTrackingMode", ctypes.c_ubyte),
        ("EffectiveOnly", ctypes.c_byte),
    ]

class CONVCONTEXT(ctypes.Structure):
    _fields_ = [
        ("cb", wintypes.DWORD),
        ("wFlags", wintypes.DWORD),
        ("wCountryID", wintypes.DWORD),
        ("iCodePage", ctypes.c_int),
        ("dwLangID", wintypes.DWORD),
        ("dwSecurity", wintypes.DWORD),
        ("qos", SECURITY_QUALITY_OF_SERVICE),
    ]
#[repr(C)]
pub struct SECURITY_QUALITY_OF_SERVICE {
    pub Length: u32,
    pub ImpersonationLevel: i32,
    pub ContextTrackingMode: u8,
    pub EffectiveOnly: u8,
}

#[repr(C)]
pub struct CONVCONTEXT {
    pub cb: u32,
    pub wFlags: u32,
    pub wCountryID: u32,
    pub iCodePage: i32,
    pub dwLangID: u32,
    pub dwSecurity: u32,
    pub qos: SECURITY_QUALITY_OF_SERVICE,
}
import "golang.org/x/sys/windows"

type SECURITY_QUALITY_OF_SERVICE struct {
	Length uint32
	ImpersonationLevel int32
	ContextTrackingMode byte
	EffectiveOnly byte
}

type CONVCONTEXT struct {
	cb uint32
	wFlags uint32
	wCountryID uint32
	iCodePage int32
	dwLangID uint32
	dwSecurity uint32
	qos SECURITY_QUALITY_OF_SERVICE
}
type
  SECURITY_QUALITY_OF_SERVICE = record
    Length: DWORD;
    ImpersonationLevel: Integer;
    ContextTrackingMode: Byte;
    EffectiveOnly: ByteBool;
  end;

  CONVCONTEXT = record
    cb: DWORD;
    wFlags: DWORD;
    wCountryID: DWORD;
    iCodePage: Integer;
    dwLangID: DWORD;
    dwSecurity: DWORD;
    qos: SECURITY_QUALITY_OF_SERVICE;
  end;
const SECURITY_QUALITY_OF_SERVICE = extern struct {
    Length: u32,
    ImpersonationLevel: i32,
    ContextTrackingMode: u8,
    EffectiveOnly: u8,
};

const CONVCONTEXT = extern struct {
    cb: u32,
    wFlags: u32,
    wCountryID: u32,
    iCodePage: i32,
    dwLangID: u32,
    dwSecurity: u32,
    qos: SECURITY_QUALITY_OF_SERVICE,
};
type
  SECURITY_QUALITY_OF_SERVICE {.bycopy.} = object
    Length: uint32
    ImpersonationLevel: int32
    ContextTrackingMode: uint8
    EffectiveOnly: uint8

  CONVCONTEXT {.bycopy.} = object
    cb: uint32
    wFlags: uint32
    wCountryID: uint32
    iCodePage: int32
    dwLangID: uint32
    dwSecurity: uint32
    qos: SECURITY_QUALITY_OF_SERVICE
struct SECURITY_QUALITY_OF_SERVICE
{
    uint Length;
    int ImpersonationLevel;
    ubyte ContextTrackingMode;
    ubyte EffectiveOnly;
}

struct CONVCONTEXT
{
    uint cb;
    uint wFlags;
    uint wCountryID;
    int iCodePage;
    uint dwLangID;
    uint dwSecurity;
    SECURITY_QUALITY_OF_SERVICE qos;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CONVCONTEXT サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; cb : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; wFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; wCountryID : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; iCodePage : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwLangID : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dwSecurity : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; qos : SECURITY_QUALITY_OF_SERVICE (+24, 12byte)  varptr(st)+24 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SECURITY_QUALITY_OF_SERVICE
    #field int Length
    #field int ImpersonationLevel
    #field byte ContextTrackingMode
    #field bool1 EffectiveOnly
#endstruct

#defstruct global CONVCONTEXT
    #field int cb
    #field int wFlags
    #field int wCountryID
    #field int iCodePage
    #field int dwLangID
    #field int dwSecurity
    #field SECURITY_QUALITY_OF_SERVICE qos
#endstruct

stdim st, CONVCONTEXT        ; NSTRUCT 変数を確保
st->cb = 100
mes "cb=" + st->cb