ホーム › Globalization › FindNLSStringEx
FindNLSStringEx
関数ロケール名を指定して文字列内から部分文字列を検索する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
INT FindNLSStringEx(
LPCWSTR lpLocaleName, // optional
DWORD dwFindNLSStringFlags,
LPCWSTR lpStringSource,
INT cchSource,
LPCWSTR lpStringValue,
INT cchValue,
INT* pcchFound, // optional
NLSVERSIONINFO* lpVersionInformation, // optional
void* lpReserved, // optional
LPARAM sortHandle
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpLocaleName | LPCWSTR | inoptional |
| dwFindNLSStringFlags | DWORD | in |
| lpStringSource | LPCWSTR | in |
| cchSource | INT | in |
| lpStringValue | LPCWSTR | in |
| cchValue | INT | in |
| pcchFound | INT* | outoptional |
| lpVersionInformation | NLSVERSIONINFO* | inoptional |
| lpReserved | void* | inoptional |
| sortHandle | LPARAM | in |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
INT FindNLSStringEx(
LPCWSTR lpLocaleName, // optional
DWORD dwFindNLSStringFlags,
LPCWSTR lpStringSource,
INT cchSource,
LPCWSTR lpStringValue,
INT cchValue,
INT* pcchFound, // optional
NLSVERSIONINFO* lpVersionInformation, // optional
void* lpReserved, // optional
LPARAM sortHandle
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern int FindNLSStringEx(
[MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, // LPCWSTR optional
uint dwFindNLSStringFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpStringSource, // LPCWSTR
int cchSource, // INT
[MarshalAs(UnmanagedType.LPWStr)] string lpStringValue, // LPCWSTR
int cchValue, // INT
IntPtr pcchFound, // INT* optional, out
IntPtr lpVersionInformation, // NLSVERSIONINFO* optional
IntPtr lpReserved, // void* optional
IntPtr sortHandle // LPARAM
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindNLSStringEx(
<MarshalAs(UnmanagedType.LPWStr)> lpLocaleName As String, ' LPCWSTR optional
dwFindNLSStringFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpStringSource As String, ' LPCWSTR
cchSource As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> lpStringValue As String, ' LPCWSTR
cchValue As Integer, ' INT
pcchFound As IntPtr, ' INT* optional, out
lpVersionInformation As IntPtr, ' NLSVERSIONINFO* optional
lpReserved As IntPtr, ' void* optional
sortHandle As IntPtr ' LPARAM
) As Integer
End Function' lpLocaleName : LPCWSTR optional
' dwFindNLSStringFlags : DWORD
' lpStringSource : LPCWSTR
' cchSource : INT
' lpStringValue : LPCWSTR
' cchValue : INT
' pcchFound : INT* optional, out
' lpVersionInformation : NLSVERSIONINFO* optional
' lpReserved : void* optional
' sortHandle : LPARAM
Declare PtrSafe Function FindNLSStringEx Lib "kernel32" ( _
ByVal lpLocaleName As LongPtr, _
ByVal dwFindNLSStringFlags As Long, _
ByVal lpStringSource As LongPtr, _
ByVal cchSource As Long, _
ByVal lpStringValue As LongPtr, _
ByVal cchValue As Long, _
ByVal pcchFound As LongPtr, _
ByVal lpVersionInformation As LongPtr, _
ByVal lpReserved As LongPtr, _
ByVal sortHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FindNLSStringEx = ctypes.windll.kernel32.FindNLSStringEx
FindNLSStringEx.restype = ctypes.c_int
FindNLSStringEx.argtypes = [
wintypes.LPCWSTR, # lpLocaleName : LPCWSTR optional
wintypes.DWORD, # dwFindNLSStringFlags : DWORD
wintypes.LPCWSTR, # lpStringSource : LPCWSTR
ctypes.c_int, # cchSource : INT
wintypes.LPCWSTR, # lpStringValue : LPCWSTR
ctypes.c_int, # cchValue : INT
ctypes.POINTER(ctypes.c_int), # pcchFound : INT* optional, out
ctypes.c_void_p, # lpVersionInformation : NLSVERSIONINFO* optional
ctypes.POINTER(None), # lpReserved : void* optional
ctypes.c_ssize_t, # sortHandle : LPARAM
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
FindNLSStringEx = Fiddle::Function.new(
lib['FindNLSStringEx'],
[
Fiddle::TYPE_VOIDP, # lpLocaleName : LPCWSTR optional
-Fiddle::TYPE_INT, # dwFindNLSStringFlags : DWORD
Fiddle::TYPE_VOIDP, # lpStringSource : LPCWSTR
Fiddle::TYPE_INT, # cchSource : INT
Fiddle::TYPE_VOIDP, # lpStringValue : LPCWSTR
Fiddle::TYPE_INT, # cchValue : INT
Fiddle::TYPE_VOIDP, # pcchFound : INT* optional, out
Fiddle::TYPE_VOIDP, # lpVersionInformation : NLSVERSIONINFO* optional
Fiddle::TYPE_VOIDP, # lpReserved : void* optional
Fiddle::TYPE_INTPTR_T, # sortHandle : LPARAM
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn FindNLSStringEx(
lpLocaleName: *const u16, // LPCWSTR optional
dwFindNLSStringFlags: u32, // DWORD
lpStringSource: *const u16, // LPCWSTR
cchSource: i32, // INT
lpStringValue: *const u16, // LPCWSTR
cchValue: i32, // INT
pcchFound: *mut i32, // INT* optional, out
lpVersionInformation: *mut NLSVERSIONINFO, // NLSVERSIONINFO* optional
lpReserved: *mut (), // void* optional
sortHandle: isize // LPARAM
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern int FindNLSStringEx([MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, uint dwFindNLSStringFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpStringSource, int cchSource, [MarshalAs(UnmanagedType.LPWStr)] string lpStringValue, int cchValue, IntPtr pcchFound, IntPtr lpVersionInformation, IntPtr lpReserved, IntPtr sortHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindNLSStringEx' -Namespace Win32 -PassThru
# $api::FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, pcchFound, lpVersionInformation, lpReserved, sortHandle)#uselib "KERNEL32.dll"
#func global FindNLSStringEx "FindNLSStringEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; FindNLSStringEx lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, varptr(pcchFound), varptr(lpVersionInformation), lpReserved, sortHandle ; 戻り値は stat
; lpLocaleName : LPCWSTR optional -> "sptr"
; dwFindNLSStringFlags : DWORD -> "sptr"
; lpStringSource : LPCWSTR -> "sptr"
; cchSource : INT -> "sptr"
; lpStringValue : LPCWSTR -> "sptr"
; cchValue : INT -> "sptr"
; pcchFound : INT* optional, out -> "sptr"
; lpVersionInformation : NLSVERSIONINFO* optional -> "sptr"
; lpReserved : void* optional -> "sptr"
; sortHandle : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global FindNLSStringEx "FindNLSStringEx" wstr, int, wstr, int, wstr, int, var, var, sptr, sptr ; res = FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, pcchFound, lpVersionInformation, lpReserved, sortHandle) ; lpLocaleName : LPCWSTR optional -> "wstr" ; dwFindNLSStringFlags : DWORD -> "int" ; lpStringSource : LPCWSTR -> "wstr" ; cchSource : INT -> "int" ; lpStringValue : LPCWSTR -> "wstr" ; cchValue : INT -> "int" ; pcchFound : INT* optional, out -> "var" ; lpVersionInformation : NLSVERSIONINFO* optional -> "var" ; lpReserved : void* optional -> "sptr" ; sortHandle : LPARAM -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global FindNLSStringEx "FindNLSStringEx" wstr, int, wstr, int, wstr, int, sptr, sptr, sptr, sptr ; res = FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, varptr(pcchFound), varptr(lpVersionInformation), lpReserved, sortHandle) ; lpLocaleName : LPCWSTR optional -> "wstr" ; dwFindNLSStringFlags : DWORD -> "int" ; lpStringSource : LPCWSTR -> "wstr" ; cchSource : INT -> "int" ; lpStringValue : LPCWSTR -> "wstr" ; cchValue : INT -> "int" ; pcchFound : INT* optional, out -> "sptr" ; lpVersionInformation : NLSVERSIONINFO* optional -> "sptr" ; lpReserved : void* optional -> "sptr" ; sortHandle : LPARAM -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT FindNLSStringEx(LPCWSTR lpLocaleName, DWORD dwFindNLSStringFlags, LPCWSTR lpStringSource, INT cchSource, LPCWSTR lpStringValue, INT cchValue, INT* pcchFound, NLSVERSIONINFO* lpVersionInformation, void* lpReserved, LPARAM sortHandle) #uselib "KERNEL32.dll" #cfunc global FindNLSStringEx "FindNLSStringEx" wstr, int, wstr, int, wstr, int, var, var, intptr, intptr ; res = FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, pcchFound, lpVersionInformation, lpReserved, sortHandle) ; lpLocaleName : LPCWSTR optional -> "wstr" ; dwFindNLSStringFlags : DWORD -> "int" ; lpStringSource : LPCWSTR -> "wstr" ; cchSource : INT -> "int" ; lpStringValue : LPCWSTR -> "wstr" ; cchValue : INT -> "int" ; pcchFound : INT* optional, out -> "var" ; lpVersionInformation : NLSVERSIONINFO* optional -> "var" ; lpReserved : void* optional -> "intptr" ; sortHandle : LPARAM -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT FindNLSStringEx(LPCWSTR lpLocaleName, DWORD dwFindNLSStringFlags, LPCWSTR lpStringSource, INT cchSource, LPCWSTR lpStringValue, INT cchValue, INT* pcchFound, NLSVERSIONINFO* lpVersionInformation, void* lpReserved, LPARAM sortHandle) #uselib "KERNEL32.dll" #cfunc global FindNLSStringEx "FindNLSStringEx" wstr, int, wstr, int, wstr, int, intptr, intptr, intptr, intptr ; res = FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, varptr(pcchFound), varptr(lpVersionInformation), lpReserved, sortHandle) ; lpLocaleName : LPCWSTR optional -> "wstr" ; dwFindNLSStringFlags : DWORD -> "int" ; lpStringSource : LPCWSTR -> "wstr" ; cchSource : INT -> "int" ; lpStringValue : LPCWSTR -> "wstr" ; cchValue : INT -> "int" ; pcchFound : INT* optional, out -> "intptr" ; lpVersionInformation : NLSVERSIONINFO* optional -> "intptr" ; lpReserved : void* optional -> "intptr" ; sortHandle : LPARAM -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procFindNLSStringEx = kernel32.NewProc("FindNLSStringEx")
)
// lpLocaleName (LPCWSTR optional), dwFindNLSStringFlags (DWORD), lpStringSource (LPCWSTR), cchSource (INT), lpStringValue (LPCWSTR), cchValue (INT), pcchFound (INT* optional, out), lpVersionInformation (NLSVERSIONINFO* optional), lpReserved (void* optional), sortHandle (LPARAM)
r1, _, err := procFindNLSStringEx.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLocaleName))),
uintptr(dwFindNLSStringFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpStringSource))),
uintptr(cchSource),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpStringValue))),
uintptr(cchValue),
uintptr(pcchFound),
uintptr(lpVersionInformation),
uintptr(lpReserved),
uintptr(sortHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction FindNLSStringEx(
lpLocaleName: PWideChar; // LPCWSTR optional
dwFindNLSStringFlags: DWORD; // DWORD
lpStringSource: PWideChar; // LPCWSTR
cchSource: Integer; // INT
lpStringValue: PWideChar; // LPCWSTR
cchValue: Integer; // INT
pcchFound: Pointer; // INT* optional, out
lpVersionInformation: Pointer; // NLSVERSIONINFO* optional
lpReserved: Pointer; // void* optional
sortHandle: NativeInt // LPARAM
): Integer; stdcall;
external 'KERNEL32.dll' name 'FindNLSStringEx';result := DllCall("KERNEL32\FindNLSStringEx"
, "WStr", lpLocaleName ; LPCWSTR optional
, "UInt", dwFindNLSStringFlags ; DWORD
, "WStr", lpStringSource ; LPCWSTR
, "Int", cchSource ; INT
, "WStr", lpStringValue ; LPCWSTR
, "Int", cchValue ; INT
, "Ptr", pcchFound ; INT* optional, out
, "Ptr", lpVersionInformation ; NLSVERSIONINFO* optional
, "Ptr", lpReserved ; void* optional
, "Ptr", sortHandle ; LPARAM
, "Int") ; return: INT●FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, pcchFound, lpVersionInformation, lpReserved, sortHandle) = DLL("KERNEL32.dll", "int FindNLSStringEx(char*, dword, char*, int, char*, int, void*, void*, void*, int)")
# 呼び出し: FindNLSStringEx(lpLocaleName, dwFindNLSStringFlags, lpStringSource, cchSource, lpStringValue, cchValue, pcchFound, lpVersionInformation, lpReserved, sortHandle)
# lpLocaleName : LPCWSTR optional -> "char*"
# dwFindNLSStringFlags : DWORD -> "dword"
# lpStringSource : LPCWSTR -> "char*"
# cchSource : INT -> "int"
# lpStringValue : LPCWSTR -> "char*"
# cchValue : INT -> "int"
# pcchFound : INT* optional, out -> "void*"
# lpVersionInformation : NLSVERSIONINFO* optional -> "void*"
# lpReserved : void* optional -> "void*"
# sortHandle : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。