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

FindAtomA

関数
指定文字列に対応するローカルアトムを検索する(ANSI)。
DLLKERNEL32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

WORD FindAtomA(
    LPCSTR lpString   // optional
);

パラメーター

名前方向
lpStringLPCSTRinoptional

戻り値の型: WORD

各言語での呼び出し定義

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

WORD FindAtomA(
    LPCSTR lpString   // optional
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern ushort FindAtomA(
    [MarshalAs(UnmanagedType.LPStr)] string lpString   // LPCSTR optional
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindAtomA(
    <MarshalAs(UnmanagedType.LPStr)> lpString As String   ' LPCSTR optional
) As UShort
End Function
' lpString : LPCSTR optional
Declare PtrSafe Function FindAtomA Lib "kernel32" ( _
    ByVal lpString As String) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FindAtomA = ctypes.windll.kernel32.FindAtomA
FindAtomA.restype = ctypes.c_ushort
FindAtomA.argtypes = [
    wintypes.LPCSTR,  # lpString : LPCSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
FindAtomA = Fiddle::Function.new(
  lib['FindAtomA'],
  [
    Fiddle::TYPE_VOIDP,  # lpString : LPCSTR optional
  ],
  -Fiddle::TYPE_SHORT)
#[link(name = "kernel32")]
extern "system" {
    fn FindAtomA(
        lpString: *const u8  // LPCSTR optional
    ) -> u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern ushort FindAtomA([MarshalAs(UnmanagedType.LPStr)] string lpString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindAtomA' -Namespace Win32 -PassThru
# $api::FindAtomA(lpString)
#uselib "KERNEL32.dll"
#func global FindAtomA "FindAtomA" sptr
; FindAtomA lpString   ; 戻り値は stat
; lpString : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global FindAtomA "FindAtomA" str
; res = FindAtomA(lpString)
; lpString : LPCSTR optional -> "str"
; WORD FindAtomA(LPCSTR lpString)
#uselib "KERNEL32.dll"
#cfunc global FindAtomA "FindAtomA" str
; res = FindAtomA(lpString)
; lpString : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindAtomA = kernel32.NewProc("FindAtomA")
)

// lpString (LPCSTR optional)
r1, _, err := procFindAtomA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpString))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WORD
function FindAtomA(
  lpString: PAnsiChar   // LPCSTR optional
): Word; stdcall;
  external 'KERNEL32.dll' name 'FindAtomA';
result := DllCall("KERNEL32\FindAtomA"
    , "AStr", lpString   ; LPCSTR optional
    , "UShort")   ; return: WORD
●FindAtomA(lpString) = DLL("KERNEL32.dll", "int FindAtomA(char*)")
# 呼び出し: FindAtomA(lpString)
# lpString : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。