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

WlanRenameProfile

関数
指定した無線LANプロファイルの名前を変更する。
DLLwlanapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD WlanRenameProfile(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    LPCWSTR strOldProfileName,
    LPCWSTR strNewProfileName,
    void* pReserved   // optional
);

パラメーター

名前方向
hClientHandleHANDLEin
pInterfaceGuidGUID*in
strOldProfileNameLPCWSTRin
strNewProfileNameLPCWSTRin
pReservedvoid*optional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WlanRenameProfile(
    HANDLE hClientHandle,
    const GUID* pInterfaceGuid,
    LPCWSTR strOldProfileName,
    LPCWSTR strNewProfileName,
    void* pReserved   // optional
);
[DllImport("wlanapi.dll", ExactSpelling = true)]
static extern uint WlanRenameProfile(
    IntPtr hClientHandle,   // HANDLE
    ref Guid pInterfaceGuid,   // GUID*
    [MarshalAs(UnmanagedType.LPWStr)] string strOldProfileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string strNewProfileName,   // LPCWSTR
    IntPtr pReserved   // void* optional
);
<DllImport("wlanapi.dll", ExactSpelling:=True)>
Public Shared Function WlanRenameProfile(
    hClientHandle As IntPtr,   ' HANDLE
    ByRef pInterfaceGuid As Guid,   ' GUID*
    <MarshalAs(UnmanagedType.LPWStr)> strOldProfileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> strNewProfileName As String,   ' LPCWSTR
    pReserved As IntPtr   ' void* optional
) As UInteger
End Function
' hClientHandle : HANDLE
' pInterfaceGuid : GUID*
' strOldProfileName : LPCWSTR
' strNewProfileName : LPCWSTR
' pReserved : void* optional
Declare PtrSafe Function WlanRenameProfile Lib "wlanapi" ( _
    ByVal hClientHandle As LongPtr, _
    ByVal pInterfaceGuid As LongPtr, _
    ByVal strOldProfileName As LongPtr, _
    ByVal strNewProfileName As LongPtr, _
    ByVal pReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WlanRenameProfile = ctypes.windll.wlanapi.WlanRenameProfile
WlanRenameProfile.restype = wintypes.DWORD
WlanRenameProfile.argtypes = [
    wintypes.HANDLE,  # hClientHandle : HANDLE
    ctypes.c_void_p,  # pInterfaceGuid : GUID*
    wintypes.LPCWSTR,  # strOldProfileName : LPCWSTR
    wintypes.LPCWSTR,  # strNewProfileName : LPCWSTR
    ctypes.POINTER(None),  # pReserved : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wlanapi.dll')
WlanRenameProfile = Fiddle::Function.new(
  lib['WlanRenameProfile'],
  [
    Fiddle::TYPE_VOIDP,  # hClientHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # pInterfaceGuid : GUID*
    Fiddle::TYPE_VOIDP,  # strOldProfileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # strNewProfileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wlanapi")]
extern "system" {
    fn WlanRenameProfile(
        hClientHandle: *mut core::ffi::c_void,  // HANDLE
        pInterfaceGuid: *const GUID,  // GUID*
        strOldProfileName: *const u16,  // LPCWSTR
        strNewProfileName: *const u16,  // LPCWSTR
        pReserved: *mut ()  // void* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wlanapi.dll")]
public static extern uint WlanRenameProfile(IntPtr hClientHandle, ref Guid pInterfaceGuid, [MarshalAs(UnmanagedType.LPWStr)] string strOldProfileName, [MarshalAs(UnmanagedType.LPWStr)] string strNewProfileName, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wlanapi_WlanRenameProfile' -Namespace Win32 -PassThru
# $api::WlanRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName, pReserved)
#uselib "wlanapi.dll"
#func global WlanRenameProfile "WlanRenameProfile" sptr, sptr, sptr, sptr, sptr
; WlanRenameProfile hClientHandle, varptr(pInterfaceGuid), strOldProfileName, strNewProfileName, pReserved   ; 戻り値は stat
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "sptr"
; strOldProfileName : LPCWSTR -> "sptr"
; strNewProfileName : LPCWSTR -> "sptr"
; pReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wlanapi.dll"
#cfunc global WlanRenameProfile "WlanRenameProfile" sptr, var, wstr, wstr, sptr
; res = WlanRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName, pReserved)
; hClientHandle : HANDLE -> "sptr"
; pInterfaceGuid : GUID* -> "var"
; strOldProfileName : LPCWSTR -> "wstr"
; strNewProfileName : LPCWSTR -> "wstr"
; pReserved : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WlanRenameProfile(HANDLE hClientHandle, GUID* pInterfaceGuid, LPCWSTR strOldProfileName, LPCWSTR strNewProfileName, void* pReserved)
#uselib "wlanapi.dll"
#cfunc global WlanRenameProfile "WlanRenameProfile" intptr, var, wstr, wstr, intptr
; res = WlanRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName, pReserved)
; hClientHandle : HANDLE -> "intptr"
; pInterfaceGuid : GUID* -> "var"
; strOldProfileName : LPCWSTR -> "wstr"
; strNewProfileName : LPCWSTR -> "wstr"
; pReserved : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wlanapi = windows.NewLazySystemDLL("wlanapi.dll")
	procWlanRenameProfile = wlanapi.NewProc("WlanRenameProfile")
)

// hClientHandle (HANDLE), pInterfaceGuid (GUID*), strOldProfileName (LPCWSTR), strNewProfileName (LPCWSTR), pReserved (void* optional)
r1, _, err := procWlanRenameProfile.Call(
	uintptr(hClientHandle),
	uintptr(pInterfaceGuid),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strOldProfileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strNewProfileName))),
	uintptr(pReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WlanRenameProfile(
  hClientHandle: THandle;   // HANDLE
  pInterfaceGuid: PGUID;   // GUID*
  strOldProfileName: PWideChar;   // LPCWSTR
  strNewProfileName: PWideChar;   // LPCWSTR
  pReserved: Pointer   // void* optional
): DWORD; stdcall;
  external 'wlanapi.dll' name 'WlanRenameProfile';
result := DllCall("wlanapi\WlanRenameProfile"
    , "Ptr", hClientHandle   ; HANDLE
    , "Ptr", pInterfaceGuid   ; GUID*
    , "WStr", strOldProfileName   ; LPCWSTR
    , "WStr", strNewProfileName   ; LPCWSTR
    , "Ptr", pReserved   ; void* optional
    , "UInt")   ; return: DWORD
●WlanRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName, pReserved) = DLL("wlanapi.dll", "dword WlanRenameProfile(void*, void*, char*, char*, void*)")
# 呼び出し: WlanRenameProfile(hClientHandle, pInterfaceGuid, strOldProfileName, strNewProfileName, pReserved)
# hClientHandle : HANDLE -> "void*"
# pInterfaceGuid : GUID* -> "void*"
# strOldProfileName : LPCWSTR -> "char*"
# strNewProfileName : LPCWSTR -> "char*"
# pReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。