ホーム › Networking.Ldap › LdapMapErrorToWin32
LdapMapErrorToWin32
関数LDAPエラーコードを対応するWin32エラーに変換する。
シグネチャ
// WLDAP32.dll
#include <windows.h>
WIN32_ERROR LdapMapErrorToWin32(
DWORD LdapError
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| LdapError | DWORD | in | 変換元のLDAPエラーコード。対応するWin32エラーコードへ写像する入力。 |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// WLDAP32.dll
#include <windows.h>
WIN32_ERROR LdapMapErrorToWin32(
DWORD LdapError
);[DllImport("WLDAP32.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint LdapMapErrorToWin32(
uint LdapError // DWORD
);<DllImport("WLDAP32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function LdapMapErrorToWin32(
LdapError As UInteger ' DWORD
) As UInteger
End Function' LdapError : DWORD
Declare PtrSafe Function LdapMapErrorToWin32 Lib "wldap32" ( _
ByVal LdapError As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LdapMapErrorToWin32 = ctypes.cdll.wldap32.LdapMapErrorToWin32
LdapMapErrorToWin32.restype = wintypes.DWORD
LdapMapErrorToWin32.argtypes = [
wintypes.DWORD, # LdapError : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
LdapMapErrorToWin32 = Fiddle::Function.new(
lib['LdapMapErrorToWin32'],
[
-Fiddle::TYPE_INT, # LdapError : DWORD
],
-Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "wldap32")]
extern "C" {
fn LdapMapErrorToWin32(
LdapError: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern uint LdapMapErrorToWin32(uint LdapError);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_LdapMapErrorToWin32' -Namespace Win32 -PassThru
# $api::LdapMapErrorToWin32(LdapError)#uselib "WLDAP32.dll"
#func global LdapMapErrorToWin32 "LdapMapErrorToWin32" sptr
; LdapMapErrorToWin32 LdapError ; 戻り値は stat
; LdapError : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WLDAP32.dll"
#cfunc global LdapMapErrorToWin32 "LdapMapErrorToWin32" int
; res = LdapMapErrorToWin32(LdapError)
; LdapError : DWORD -> "int"; WIN32_ERROR LdapMapErrorToWin32(DWORD LdapError)
#uselib "WLDAP32.dll"
#cfunc global LdapMapErrorToWin32 "LdapMapErrorToWin32" int
; res = LdapMapErrorToWin32(LdapError)
; LdapError : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procLdapMapErrorToWin32 = wldap32.NewProc("LdapMapErrorToWin32")
)
// LdapError (DWORD)
r1, _, err := procLdapMapErrorToWin32.Call(
uintptr(LdapError),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction LdapMapErrorToWin32(
LdapError: DWORD // DWORD
): DWORD; cdecl;
external 'WLDAP32.dll' name 'LdapMapErrorToWin32';result := DllCall("WLDAP32\LdapMapErrorToWin32"
, "UInt", LdapError ; DWORD
, "Cdecl UInt") ; return: WIN32_ERROR●LdapMapErrorToWin32(LdapError) = DLL("WLDAP32.dll", "dword LdapMapErrorToWin32(dword)")
# 呼び出し: LdapMapErrorToWin32(LdapError)
# LdapError : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn LdapMapErrorToWin32(
LdapError: u32 // DWORD
) callconv(.c) u32;proc LdapMapErrorToWin32(
LdapError: uint32 # DWORD
): uint32 {.importc: "LdapMapErrorToWin32", cdecl, dynlib: "WLDAP32.dll".}pragma(lib, "wldap32");
extern(C)
uint LdapMapErrorToWin32(
uint LdapError // DWORD
);ccall((:LdapMapErrorToWin32, "WLDAP32.dll"), UInt32,
(UInt32,),
LdapError)
# LdapError : DWORD -> UInt32local ffi = require("ffi")
ffi.cdef[[
uint32_t LdapMapErrorToWin32(
uint32_t LdapError);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.LdapMapErrorToWin32(LdapError)
-- LdapError : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const LdapMapErrorToWin32 = lib.func('__cdecl', 'LdapMapErrorToWin32', 'uint32_t', ['uint32_t']);
// LdapMapErrorToWin32(LdapError)
// LdapError : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
LdapMapErrorToWin32: { parameters: ["u32"], result: "u32" },
});
// lib.symbols.LdapMapErrorToWin32(LdapError)
// LdapError : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t LdapMapErrorToWin32(
uint32_t LdapError);
C, "WLDAP32.dll");
// $ffi->LdapMapErrorToWin32(LdapError);
// LdapError : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wldap32 extends Library {
Wldap32 INSTANCE = Native.load("wldap32", Wldap32.class);
int LdapMapErrorToWin32(
int LdapError // DWORD
);
}@[Link("wldap32")]
lib LibWLDAP32
fun LdapMapErrorToWin32 = LdapMapErrorToWin32(
LdapError : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef LdapMapErrorToWin32Native = Uint32 Function(Uint32);
typedef LdapMapErrorToWin32Dart = int Function(int);
final LdapMapErrorToWin32 = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<LdapMapErrorToWin32Native, LdapMapErrorToWin32Dart>('LdapMapErrorToWin32');
// LdapError : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LdapMapErrorToWin32(
LdapError: DWORD // DWORD
): DWORD; cdecl;
external 'WLDAP32.dll' name 'LdapMapErrorToWin32';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "LdapMapErrorToWin32"
c_LdapMapErrorToWin32 :: Word32 -> IO Word32
-- LdapError : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldapmaperrortowin32 =
foreign "LdapMapErrorToWin32"
(uint32_t @-> returning uint32_t)
(* LdapError : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("LdapMapErrorToWin32" ldap-map-error-to-win32 :convention :cdecl) :uint32
(ldap-error :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LdapMapErrorToWin32 = Win32::API::More->new('WLDAP32',
'DWORD LdapMapErrorToWin32(DWORD LdapError)');
# my $ret = $LdapMapErrorToWin32->Call($LdapError);
# LdapError : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型