Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsFirewall › NcIsValidConnectionName

NcIsValidConnectionName

関数
指定した文字列が有効なネットワーク接続名かを判定する。
DLLNetshell.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// Netshell.dll
#include <windows.h>

BOOL NcIsValidConnectionName(
    LPCWSTR pszwName
);

パラメーター

名前方向
pszwNameLPCWSTRin

戻り値の型: 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 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   // BOOL
function 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)。