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

FindAtomW

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

シグネチャ

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

WORD FindAtomW(
    LPCWSTR lpString   // optional
);

パラメーター

名前方向
lpStringLPCWSTRinoptional

戻り値の型: WORD

各言語での呼び出し定義

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

WORD FindAtomW(
    LPCWSTR lpString   // optional
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern ushort FindAtomW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpString   // LPCWSTR optional
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindAtomW(
    <MarshalAs(UnmanagedType.LPWStr)> lpString As String   ' LPCWSTR optional
) As UShort
End Function
' lpString : LPCWSTR optional
Declare PtrSafe Function FindAtomW Lib "kernel32" ( _
    ByVal lpString As LongPtr) As Integer
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindAtomW = kernel32.NewProc("FindAtomW")
)

// lpString (LPCWSTR optional)
r1, _, err := procFindAtomW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpString))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WORD
function FindAtomW(
  lpString: PWideChar   // LPCWSTR optional
): Word; stdcall;
  external 'KERNEL32.dll' name 'FindAtomW';
result := DllCall("KERNEL32\FindAtomW"
    , "WStr", lpString   ; LPCWSTR optional
    , "UShort")   ; return: WORD
●FindAtomW(lpString) = DLL("KERNEL32.dll", "int FindAtomW(char*)")
# 呼び出し: FindAtomW(lpString)
# lpString : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。