ホーム › System.DataExchange › GetAtomNameA
GetAtomNameA
関数ローカルアトムに関連付けられた文字列を取得する(ANSI)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetAtomNameA(
WORD nAtom,
LPSTR lpBuffer,
INT nSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| nAtom | WORD | in |
| lpBuffer | LPSTR | out |
| nSize | INT | in |
戻り値の型: DWORD
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetAtomNameA(
WORD nAtom,
LPSTR lpBuffer,
INT nSize
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint GetAtomNameA(
ushort nAtom, // WORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, // LPSTR out
int nSize // INT
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetAtomNameA(
nAtom As UShort, ' WORD
<MarshalAs(UnmanagedType.LPStr)> lpBuffer As System.Text.StringBuilder, ' LPSTR out
nSize As Integer ' INT
) As UInteger
End Function' nAtom : WORD
' lpBuffer : LPSTR out
' nSize : INT
Declare PtrSafe Function GetAtomNameA Lib "kernel32" ( _
ByVal nAtom As Integer, _
ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetAtomNameA = ctypes.windll.kernel32.GetAtomNameA
GetAtomNameA.restype = wintypes.DWORD
GetAtomNameA.argtypes = [
ctypes.c_ushort, # nAtom : WORD
wintypes.LPSTR, # lpBuffer : LPSTR out
ctypes.c_int, # nSize : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetAtomNameA = Fiddle::Function.new(
lib['GetAtomNameA'],
[
-Fiddle::TYPE_SHORT, # nAtom : WORD
Fiddle::TYPE_VOIDP, # lpBuffer : LPSTR out
Fiddle::TYPE_INT, # nSize : INT
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetAtomNameA(
nAtom: u16, // WORD
lpBuffer: *mut u8, // LPSTR out
nSize: i32 // INT
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint GetAtomNameA(ushort nAtom, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, int nSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetAtomNameA' -Namespace Win32 -PassThru
# $api::GetAtomNameA(nAtom, lpBuffer, nSize)#uselib "KERNEL32.dll"
#func global GetAtomNameA "GetAtomNameA" sptr, sptr, sptr
; GetAtomNameA nAtom, varptr(lpBuffer), nSize ; 戻り値は stat
; nAtom : WORD -> "sptr"
; lpBuffer : LPSTR out -> "sptr"
; nSize : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetAtomNameA "GetAtomNameA" int, var, int ; res = GetAtomNameA(nAtom, lpBuffer, nSize) ; nAtom : WORD -> "int" ; lpBuffer : LPSTR out -> "var" ; nSize : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetAtomNameA "GetAtomNameA" int, sptr, int ; res = GetAtomNameA(nAtom, varptr(lpBuffer), nSize) ; nAtom : WORD -> "int" ; lpBuffer : LPSTR out -> "sptr" ; nSize : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetAtomNameA(WORD nAtom, LPSTR lpBuffer, INT nSize) #uselib "KERNEL32.dll" #cfunc global GetAtomNameA "GetAtomNameA" int, var, int ; res = GetAtomNameA(nAtom, lpBuffer, nSize) ; nAtom : WORD -> "int" ; lpBuffer : LPSTR out -> "var" ; nSize : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetAtomNameA(WORD nAtom, LPSTR lpBuffer, INT nSize) #uselib "KERNEL32.dll" #cfunc global GetAtomNameA "GetAtomNameA" int, intptr, int ; res = GetAtomNameA(nAtom, varptr(lpBuffer), nSize) ; nAtom : WORD -> "int" ; lpBuffer : LPSTR out -> "intptr" ; nSize : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetAtomNameA = kernel32.NewProc("GetAtomNameA")
)
// nAtom (WORD), lpBuffer (LPSTR out), nSize (INT)
r1, _, err := procGetAtomNameA.Call(
uintptr(nAtom),
uintptr(lpBuffer),
uintptr(nSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetAtomNameA(
nAtom: Word; // WORD
lpBuffer: PAnsiChar; // LPSTR out
nSize: Integer // INT
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetAtomNameA';result := DllCall("KERNEL32\GetAtomNameA"
, "UShort", nAtom ; WORD
, "Ptr", lpBuffer ; LPSTR out
, "Int", nSize ; INT
, "UInt") ; return: DWORD●GetAtomNameA(nAtom, lpBuffer, nSize) = DLL("KERNEL32.dll", "dword GetAtomNameA(int, char*, int)")
# 呼び出し: GetAtomNameA(nAtom, lpBuffer, nSize)
# nAtom : WORD -> "int"
# lpBuffer : LPSTR out -> "char*"
# nSize : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。