ホーム › Networking.ActiveDirectory › DsGetSiteNameW
DsGetSiteNameW
関数指定コンピューターが属するサイト名を取得する。
シグネチャ
// NETAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD DsGetSiteNameW(
LPCWSTR ComputerName, // optional
LPWSTR* SiteName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ComputerName | LPCWSTR | inoptional |
| SiteName | LPWSTR* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD DsGetSiteNameW(
LPCWSTR ComputerName, // optional
LPWSTR* SiteName
);[DllImport("NETAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsGetSiteNameW(
[MarshalAs(UnmanagedType.LPWStr)] string ComputerName, // LPCWSTR optional
IntPtr SiteName // LPWSTR* out
);<DllImport("NETAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsGetSiteNameW(
<MarshalAs(UnmanagedType.LPWStr)> ComputerName As String, ' LPCWSTR optional
SiteName As IntPtr ' LPWSTR* out
) As UInteger
End Function' ComputerName : LPCWSTR optional
' SiteName : LPWSTR* out
Declare PtrSafe Function DsGetSiteNameW Lib "netapi32" ( _
ByVal ComputerName As LongPtr, _
ByVal SiteName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DsGetSiteNameW = ctypes.windll.netapi32.DsGetSiteNameW
DsGetSiteNameW.restype = wintypes.DWORD
DsGetSiteNameW.argtypes = [
wintypes.LPCWSTR, # ComputerName : LPCWSTR optional
ctypes.c_void_p, # SiteName : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
DsGetSiteNameW = Fiddle::Function.new(
lib['DsGetSiteNameW'],
[
Fiddle::TYPE_VOIDP, # ComputerName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # SiteName : LPWSTR* out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "netapi32")]
extern "system" {
fn DsGetSiteNameW(
ComputerName: *const u16, // LPCWSTR optional
SiteName: *mut *mut u16 // LPWSTR* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint DsGetSiteNameW([MarshalAs(UnmanagedType.LPWStr)] string ComputerName, IntPtr SiteName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_DsGetSiteNameW' -Namespace Win32 -PassThru
# $api::DsGetSiteNameW(ComputerName, SiteName)#uselib "NETAPI32.dll"
#func global DsGetSiteNameW "DsGetSiteNameW" wptr, wptr
; DsGetSiteNameW ComputerName, varptr(SiteName) ; 戻り値は stat
; ComputerName : LPCWSTR optional -> "wptr"
; SiteName : LPWSTR* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NETAPI32.dll" #cfunc global DsGetSiteNameW "DsGetSiteNameW" wstr, var ; res = DsGetSiteNameW(ComputerName, SiteName) ; ComputerName : LPCWSTR optional -> "wstr" ; SiteName : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NETAPI32.dll" #cfunc global DsGetSiteNameW "DsGetSiteNameW" wstr, sptr ; res = DsGetSiteNameW(ComputerName, varptr(SiteName)) ; ComputerName : LPCWSTR optional -> "wstr" ; SiteName : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DsGetSiteNameW(LPCWSTR ComputerName, LPWSTR* SiteName) #uselib "NETAPI32.dll" #cfunc global DsGetSiteNameW "DsGetSiteNameW" wstr, var ; res = DsGetSiteNameW(ComputerName, SiteName) ; ComputerName : LPCWSTR optional -> "wstr" ; SiteName : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DsGetSiteNameW(LPCWSTR ComputerName, LPWSTR* SiteName) #uselib "NETAPI32.dll" #cfunc global DsGetSiteNameW "DsGetSiteNameW" wstr, intptr ; res = DsGetSiteNameW(ComputerName, varptr(SiteName)) ; ComputerName : LPCWSTR optional -> "wstr" ; SiteName : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procDsGetSiteNameW = netapi32.NewProc("DsGetSiteNameW")
)
// ComputerName (LPCWSTR optional), SiteName (LPWSTR* out)
r1, _, err := procDsGetSiteNameW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ComputerName))),
uintptr(SiteName),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DsGetSiteNameW(
ComputerName: PWideChar; // LPCWSTR optional
SiteName: PPWideChar // LPWSTR* out
): DWORD; stdcall;
external 'NETAPI32.dll' name 'DsGetSiteNameW';result := DllCall("NETAPI32\DsGetSiteNameW"
, "WStr", ComputerName ; LPCWSTR optional
, "Ptr", SiteName ; LPWSTR* out
, "UInt") ; return: DWORD●DsGetSiteNameW(ComputerName, SiteName) = DLL("NETAPI32.dll", "dword DsGetSiteNameW(char*, void*)")
# 呼び出し: DsGetSiteNameW(ComputerName, SiteName)
# ComputerName : LPCWSTR optional -> "char*"
# SiteName : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。