ホーム › NetworkManagement.WindowsFirewall › NcIsValidConnectionName
NcIsValidConnectionName
関数指定した文字列が有効なネットワーク接続名かを判定する。
シグネチャ
// Netshell.dll
#include <windows.h>
BOOL NcIsValidConnectionName(
LPCWSTR pszwName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszwName | LPCWSTR | in | 妥当性を検証するネットワーク接続名のワイド文字列。 |
戻り値の型: BOOL
各言語での呼び出し定義
// Netshell.dll
#include <windows.h>
BOOL NcIsValidConnectionName(
LPCWSTR pszwName
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Netshell.dll", ExactSpelling = true)]
static extern bool NcIsValidConnectionName(
[MarshalAs(UnmanagedType.LPWStr)] string pszwName // LPCWSTR
);<DllImport("Netshell.dll", ExactSpelling:=True)>
Public Shared Function NcIsValidConnectionName(
<MarshalAs(UnmanagedType.LPWStr)> pszwName As String ' LPCWSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pszwName : LPCWSTR
Declare PtrSafe Function NcIsValidConnectionName Lib "netshell" ( _
ByVal pszwName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NcIsValidConnectionName = ctypes.windll.netshell.NcIsValidConnectionName
NcIsValidConnectionName.restype = wintypes.BOOL
NcIsValidConnectionName.argtypes = [
wintypes.LPCWSTR, # pszwName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Netshell.dll')
NcIsValidConnectionName = Fiddle::Function.new(
lib['NcIsValidConnectionName'],
[
Fiddle::TYPE_VOIDP, # pszwName : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "netshell")]
extern "system" {
fn NcIsValidConnectionName(
pszwName: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Netshell.dll")]
public static extern bool NcIsValidConnectionName([MarshalAs(UnmanagedType.LPWStr)] string pszwName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Netshell_NcIsValidConnectionName' -Namespace Win32 -PassThru
# $api::NcIsValidConnectionName(pszwName)#uselib "Netshell.dll"
#func global NcIsValidConnectionName "NcIsValidConnectionName" sptr
; NcIsValidConnectionName pszwName ; 戻り値は stat
; pszwName : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "Netshell.dll"
#cfunc global NcIsValidConnectionName "NcIsValidConnectionName" wstr
; res = NcIsValidConnectionName(pszwName)
; pszwName : LPCWSTR -> "wstr"; BOOL NcIsValidConnectionName(LPCWSTR pszwName)
#uselib "Netshell.dll"
#cfunc global NcIsValidConnectionName "NcIsValidConnectionName" wstr
; res = NcIsValidConnectionName(pszwName)
; pszwName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netshell = windows.NewLazySystemDLL("Netshell.dll")
procNcIsValidConnectionName = netshell.NewProc("NcIsValidConnectionName")
)
// pszwName (LPCWSTR)
r1, _, err := procNcIsValidConnectionName.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszwName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction NcIsValidConnectionName(
pszwName: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'Netshell.dll' name 'NcIsValidConnectionName';result := DllCall("Netshell\NcIsValidConnectionName"
, "WStr", pszwName ; LPCWSTR
, "Int") ; return: BOOL●NcIsValidConnectionName(pszwName) = DLL("Netshell.dll", "bool NcIsValidConnectionName(char*)")
# 呼び出し: NcIsValidConnectionName(pszwName)
# pszwName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "netshell" fn NcIsValidConnectionName(
pszwName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc NcIsValidConnectionName(
pszwName: WideCString # LPCWSTR
): int32 {.importc: "NcIsValidConnectionName", stdcall, dynlib: "Netshell.dll".}pragma(lib, "netshell");
extern(Windows)
int NcIsValidConnectionName(
const(wchar)* pszwName // LPCWSTR
);ccall((:NcIsValidConnectionName, "Netshell.dll"), stdcall, Int32,
(Cwstring,),
pszwName)
# pszwName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NcIsValidConnectionName(
const uint16_t* pszwName);
]]
local netshell = ffi.load("netshell")
-- netshell.NcIsValidConnectionName(pszwName)
-- pszwName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('Netshell.dll');
const NcIsValidConnectionName = lib.func('__stdcall', 'NcIsValidConnectionName', 'int32_t', ['str16']);
// NcIsValidConnectionName(pszwName)
// pszwName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("Netshell.dll", {
NcIsValidConnectionName: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.NcIsValidConnectionName(pszwName)
// pszwName : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NcIsValidConnectionName(
const uint16_t* pszwName);
C, "Netshell.dll");
// $ffi->NcIsValidConnectionName(pszwName);
// pszwName : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Netshell extends StdCallLibrary {
Netshell INSTANCE = Native.load("netshell", Netshell.class);
boolean NcIsValidConnectionName(
WString pszwName // LPCWSTR
);
}@[Link("netshell")]
lib LibNetshell
fun NcIsValidConnectionName = NcIsValidConnectionName(
pszwName : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NcIsValidConnectionNameNative = Int32 Function(Pointer<Utf16>);
typedef NcIsValidConnectionNameDart = int Function(Pointer<Utf16>);
final NcIsValidConnectionName = DynamicLibrary.open('Netshell.dll')
.lookupFunction<NcIsValidConnectionNameNative, NcIsValidConnectionNameDart>('NcIsValidConnectionName');
// pszwName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NcIsValidConnectionName(
pszwName: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'Netshell.dll' name 'NcIsValidConnectionName';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NcIsValidConnectionName"
c_NcIsValidConnectionName :: CWString -> IO CInt
-- pszwName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ncisvalidconnectionname =
foreign "NcIsValidConnectionName"
((ptr uint16_t) @-> returning int32_t)
(* pszwName : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netshell (t "Netshell.dll"))
(cffi:use-foreign-library netshell)
(cffi:defcfun ("NcIsValidConnectionName" nc-is-valid-connection-name :convention :stdcall) :int32
(pszw-name (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NcIsValidConnectionName = Win32::API::More->new('Netshell',
'BOOL NcIsValidConnectionName(LPCWSTR pszwName)');
# my $ret = $NcIsValidConnectionName->Call($pszwName);
# pszwName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。