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

WindowsGetStringLen

関数
HSTRINGの文字数(長さ)を取得する。
DLLapi-ms-win-core-winrt-string-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-winrt-string-l1-1-0.dll
#include <windows.h>

DWORD WindowsGetStringLen(
    HSTRING string   // optional
);

パラメーター

名前方向
stringHSTRINGinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// api-ms-win-core-winrt-string-l1-1-0.dll
#include <windows.h>

DWORD WindowsGetStringLen(
    HSTRING string   // optional
);
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", ExactSpelling = true)]
static extern uint WindowsGetStringLen(
    IntPtr string   // HSTRING optional
);
<DllImport("api-ms-win-core-winrt-string-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function WindowsGetStringLen(
    [string] As IntPtr   ' HSTRING optional
) As UInteger
End Function
' string : HSTRING optional
Declare PtrSafe Function WindowsGetStringLen Lib "api-ms-win-core-winrt-string-l1-1-0" ( _
    ByVal string As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WindowsGetStringLen = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-string-l1-1-0.dll").WindowsGetStringLen
WindowsGetStringLen.restype = wintypes.DWORD
WindowsGetStringLen.argtypes = [
    wintypes.HANDLE,  # string : HSTRING optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-winrt-string-l1-1-0.dll')
WindowsGetStringLen = Fiddle::Function.new(
  lib['WindowsGetStringLen'],
  [
    Fiddle::TYPE_VOIDP,  # string : HSTRING optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-winrt-string-l1-1-0")]
extern "system" {
    fn WindowsGetStringLen(
        string: *mut core::ffi::c_void  // HSTRING optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-core-winrt-string-l1-1-0.dll")]
public static extern uint WindowsGetStringLen(IntPtr string);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-string-l1-1-0_WindowsGetStringLen' -Namespace Win32 -PassThru
# $api::WindowsGetStringLen(string)
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#func global WindowsGetStringLen "WindowsGetStringLen" sptr
; WindowsGetStringLen string   ; 戻り値は stat
; string : HSTRING optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#cfunc global WindowsGetStringLen "WindowsGetStringLen" sptr
; res = WindowsGetStringLen(string)
; string : HSTRING optional -> "sptr"
; DWORD WindowsGetStringLen(HSTRING string)
#uselib "api-ms-win-core-winrt-string-l1-1-0.dll"
#cfunc global WindowsGetStringLen "WindowsGetStringLen" intptr
; res = WindowsGetStringLen(string)
; string : HSTRING optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_winrt_string_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-winrt-string-l1-1-0.dll")
	procWindowsGetStringLen = api_ms_win_core_winrt_string_l1_1_0.NewProc("WindowsGetStringLen")
)

// string (HSTRING optional)
r1, _, err := procWindowsGetStringLen.Call(
	uintptr(string),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WindowsGetStringLen(
  string: THandle   // HSTRING optional
): DWORD; stdcall;
  external 'api-ms-win-core-winrt-string-l1-1-0.dll' name 'WindowsGetStringLen';
result := DllCall("api-ms-win-core-winrt-string-l1-1-0\WindowsGetStringLen"
    , "Ptr", string   ; HSTRING optional
    , "UInt")   ; return: DWORD
●WindowsGetStringLen(string) = DLL("api-ms-win-core-winrt-string-l1-1-0.dll", "dword WindowsGetStringLen(void*)")
# 呼び出し: WindowsGetStringLen(string)
# string : HSTRING optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。