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

WcmSetProfileList

関数
接続プロファイルの優先順位リストを設定する。
DLLwcmapi.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD WcmSetProfileList(
    WCM_PROFILE_INFO_LIST* pProfileList,
    DWORD dwPosition,
    BOOL fIgnoreUnknownProfiles,
    void* pReserved   // optional
);

パラメーター

名前方向説明
pProfileListWCM_PROFILE_INFO_LIST*in優先順位を設定するプロファイル一覧へのポインター。
dwPositionDWORDinプロファイル一覧を適用する優先順位上の位置。
fIgnoreUnknownProfilesBOOLinTRUEなら一覧にない未知のプロファイルを無視する。
pReservedvoid*optional予約領域。NULLを指定する必要がある。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WcmSetProfileList(
    WCM_PROFILE_INFO_LIST* pProfileList,
    DWORD dwPosition,
    BOOL fIgnoreUnknownProfiles,
    void* pReserved   // optional
);
[DllImport("wcmapi.dll", ExactSpelling = true)]
static extern uint WcmSetProfileList(
    IntPtr pProfileList,   // WCM_PROFILE_INFO_LIST*
    uint dwPosition,   // DWORD
    bool fIgnoreUnknownProfiles,   // BOOL
    IntPtr pReserved   // void* optional
);
<DllImport("wcmapi.dll", ExactSpelling:=True)>
Public Shared Function WcmSetProfileList(
    pProfileList As IntPtr,   ' WCM_PROFILE_INFO_LIST*
    dwPosition As UInteger,   ' DWORD
    fIgnoreUnknownProfiles As Boolean,   ' BOOL
    pReserved As IntPtr   ' void* optional
) As UInteger
End Function
' pProfileList : WCM_PROFILE_INFO_LIST*
' dwPosition : DWORD
' fIgnoreUnknownProfiles : BOOL
' pReserved : void* optional
Declare PtrSafe Function WcmSetProfileList Lib "wcmapi" ( _
    ByVal pProfileList As LongPtr, _
    ByVal dwPosition As Long, _
    ByVal fIgnoreUnknownProfiles As Long, _
    ByVal pReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WcmSetProfileList = ctypes.windll.wcmapi.WcmSetProfileList
WcmSetProfileList.restype = wintypes.DWORD
WcmSetProfileList.argtypes = [
    ctypes.c_void_p,  # pProfileList : WCM_PROFILE_INFO_LIST*
    wintypes.DWORD,  # dwPosition : DWORD
    wintypes.BOOL,  # fIgnoreUnknownProfiles : BOOL
    ctypes.POINTER(None),  # pReserved : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wcmapi.dll')
WcmSetProfileList = Fiddle::Function.new(
  lib['WcmSetProfileList'],
  [
    Fiddle::TYPE_VOIDP,  # pProfileList : WCM_PROFILE_INFO_LIST*
    -Fiddle::TYPE_INT,  # dwPosition : DWORD
    Fiddle::TYPE_INT,  # fIgnoreUnknownProfiles : BOOL
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wcmapi")]
extern "system" {
    fn WcmSetProfileList(
        pProfileList: *mut WCM_PROFILE_INFO_LIST,  // WCM_PROFILE_INFO_LIST*
        dwPosition: u32,  // DWORD
        fIgnoreUnknownProfiles: i32,  // BOOL
        pReserved: *mut ()  // void* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wcmapi.dll")]
public static extern uint WcmSetProfileList(IntPtr pProfileList, uint dwPosition, bool fIgnoreUnknownProfiles, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wcmapi_WcmSetProfileList' -Namespace Win32 -PassThru
# $api::WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
#uselib "wcmapi.dll"
#func global WcmSetProfileList "WcmSetProfileList" sptr, sptr, sptr, sptr
; WcmSetProfileList varptr(pProfileList), dwPosition, fIgnoreUnknownProfiles, pReserved   ; 戻り値は stat
; pProfileList : WCM_PROFILE_INFO_LIST* -> "sptr"
; dwPosition : DWORD -> "sptr"
; fIgnoreUnknownProfiles : BOOL -> "sptr"
; pReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wcmapi.dll"
#cfunc global WcmSetProfileList "WcmSetProfileList" var, int, int, sptr
; res = WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
; pProfileList : WCM_PROFILE_INFO_LIST* -> "var"
; dwPosition : DWORD -> "int"
; fIgnoreUnknownProfiles : BOOL -> "int"
; pReserved : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WcmSetProfileList(WCM_PROFILE_INFO_LIST* pProfileList, DWORD dwPosition, BOOL fIgnoreUnknownProfiles, void* pReserved)
#uselib "wcmapi.dll"
#cfunc global WcmSetProfileList "WcmSetProfileList" var, int, int, intptr
; res = WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
; pProfileList : WCM_PROFILE_INFO_LIST* -> "var"
; dwPosition : DWORD -> "int"
; fIgnoreUnknownProfiles : BOOL -> "int"
; pReserved : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wcmapi = windows.NewLazySystemDLL("wcmapi.dll")
	procWcmSetProfileList = wcmapi.NewProc("WcmSetProfileList")
)

// pProfileList (WCM_PROFILE_INFO_LIST*), dwPosition (DWORD), fIgnoreUnknownProfiles (BOOL), pReserved (void* optional)
r1, _, err := procWcmSetProfileList.Call(
	uintptr(pProfileList),
	uintptr(dwPosition),
	uintptr(fIgnoreUnknownProfiles),
	uintptr(pReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WcmSetProfileList(
  pProfileList: Pointer;   // WCM_PROFILE_INFO_LIST*
  dwPosition: DWORD;   // DWORD
  fIgnoreUnknownProfiles: BOOL;   // BOOL
  pReserved: Pointer   // void* optional
): DWORD; stdcall;
  external 'wcmapi.dll' name 'WcmSetProfileList';
result := DllCall("wcmapi\WcmSetProfileList"
    , "Ptr", pProfileList   ; WCM_PROFILE_INFO_LIST*
    , "UInt", dwPosition   ; DWORD
    , "Int", fIgnoreUnknownProfiles   ; BOOL
    , "Ptr", pReserved   ; void* optional
    , "UInt")   ; return: DWORD
●WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved) = DLL("wcmapi.dll", "dword WcmSetProfileList(void*, dword, bool, void*)")
# 呼び出し: WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
# pProfileList : WCM_PROFILE_INFO_LIST* -> "void*"
# dwPosition : DWORD -> "dword"
# fIgnoreUnknownProfiles : BOOL -> "bool"
# pReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wcmapi" fn WcmSetProfileList(
    pProfileList: [*c]WCM_PROFILE_INFO_LIST, // WCM_PROFILE_INFO_LIST*
    dwPosition: u32, // DWORD
    fIgnoreUnknownProfiles: i32, // BOOL
    pReserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;
proc WcmSetProfileList(
    pProfileList: ptr WCM_PROFILE_INFO_LIST,  # WCM_PROFILE_INFO_LIST*
    dwPosition: uint32,  # DWORD
    fIgnoreUnknownProfiles: int32,  # BOOL
    pReserved: pointer  # void* optional
): uint32 {.importc: "WcmSetProfileList", stdcall, dynlib: "wcmapi.dll".}
pragma(lib, "wcmapi");
extern(Windows)
uint WcmSetProfileList(
    WCM_PROFILE_INFO_LIST* pProfileList,   // WCM_PROFILE_INFO_LIST*
    uint dwPosition,   // DWORD
    int fIgnoreUnknownProfiles,   // BOOL
    void* pReserved   // void* optional
);
ccall((:WcmSetProfileList, "wcmapi.dll"), stdcall, UInt32,
      (Ptr{WCM_PROFILE_INFO_LIST}, UInt32, Int32, Ptr{Cvoid}),
      pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
# pProfileList : WCM_PROFILE_INFO_LIST* -> Ptr{WCM_PROFILE_INFO_LIST}
# dwPosition : DWORD -> UInt32
# fIgnoreUnknownProfiles : BOOL -> Int32
# pReserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WcmSetProfileList(
    void* pProfileList,
    uint32_t dwPosition,
    int32_t fIgnoreUnknownProfiles,
    void* pReserved);
]]
local wcmapi = ffi.load("wcmapi")
-- wcmapi.WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
-- pProfileList : WCM_PROFILE_INFO_LIST*
-- dwPosition : DWORD
-- fIgnoreUnknownProfiles : BOOL
-- pReserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wcmapi.dll');
const WcmSetProfileList = lib.func('__stdcall', 'WcmSetProfileList', 'uint32_t', ['void *', 'uint32_t', 'int32_t', 'void *']);
// WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
// pProfileList : WCM_PROFILE_INFO_LIST* -> 'void *'
// dwPosition : DWORD -> 'uint32_t'
// fIgnoreUnknownProfiles : BOOL -> 'int32_t'
// pReserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wcmapi.dll", {
  WcmSetProfileList: { parameters: ["pointer", "u32", "i32", "pointer"], result: "u32" },
});
// lib.symbols.WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved)
// pProfileList : WCM_PROFILE_INFO_LIST* -> "pointer"
// dwPosition : DWORD -> "u32"
// fIgnoreUnknownProfiles : BOOL -> "i32"
// pReserved : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WcmSetProfileList(
    void* pProfileList,
    uint32_t dwPosition,
    int32_t fIgnoreUnknownProfiles,
    void* pReserved);
C, "wcmapi.dll");
// $ffi->WcmSetProfileList(pProfileList, dwPosition, fIgnoreUnknownProfiles, pReserved);
// pProfileList : WCM_PROFILE_INFO_LIST*
// dwPosition : DWORD
// fIgnoreUnknownProfiles : BOOL
// pReserved : void* optional
// 構造体/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 Wcmapi extends StdCallLibrary {
    Wcmapi INSTANCE = Native.load("wcmapi", Wcmapi.class);
    int WcmSetProfileList(
        Pointer pProfileList,   // WCM_PROFILE_INFO_LIST*
        int dwPosition,   // DWORD
        boolean fIgnoreUnknownProfiles,   // BOOL
        Pointer pReserved   // void* optional
    );
}
@[Link("wcmapi")]
lib Libwcmapi
  fun WcmSetProfileList = WcmSetProfileList(
    pProfileList : WCM_PROFILE_INFO_LIST*,   # WCM_PROFILE_INFO_LIST*
    dwPosition : UInt32,   # DWORD
    fIgnoreUnknownProfiles : Int32,   # BOOL
    pReserved : Void*   # void* optional
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WcmSetProfileListNative = Uint32 Function(Pointer<Void>, Uint32, Int32, Pointer<Void>);
typedef WcmSetProfileListDart = int Function(Pointer<Void>, int, int, Pointer<Void>);
final WcmSetProfileList = DynamicLibrary.open('wcmapi.dll')
    .lookupFunction<WcmSetProfileListNative, WcmSetProfileListDart>('WcmSetProfileList');
// pProfileList : WCM_PROFILE_INFO_LIST* -> Pointer<Void>
// dwPosition : DWORD -> Uint32
// fIgnoreUnknownProfiles : BOOL -> Int32
// pReserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WcmSetProfileList(
  pProfileList: Pointer;   // WCM_PROFILE_INFO_LIST*
  dwPosition: DWORD;   // DWORD
  fIgnoreUnknownProfiles: BOOL;   // BOOL
  pReserved: Pointer   // void* optional
): DWORD; stdcall;
  external 'wcmapi.dll' name 'WcmSetProfileList';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WcmSetProfileList"
  c_WcmSetProfileList :: Ptr () -> Word32 -> CInt -> Ptr () -> IO Word32
-- pProfileList : WCM_PROFILE_INFO_LIST* -> Ptr ()
-- dwPosition : DWORD -> Word32
-- fIgnoreUnknownProfiles : BOOL -> CInt
-- pReserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wcmsetprofilelist =
  foreign "WcmSetProfileList"
    ((ptr void) @-> uint32_t @-> int32_t @-> (ptr void) @-> returning uint32_t)
(* pProfileList : WCM_PROFILE_INFO_LIST* -> (ptr void) *)
(* dwPosition : DWORD -> uint32_t *)
(* fIgnoreUnknownProfiles : BOOL -> int32_t *)
(* pReserved : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wcmapi (t "wcmapi.dll"))
(cffi:use-foreign-library wcmapi)

(cffi:defcfun ("WcmSetProfileList" wcm-set-profile-list :convention :stdcall) :uint32
  (p-profile-list :pointer)   ; WCM_PROFILE_INFO_LIST*
  (dw-position :uint32)   ; DWORD
  (f-ignore-unknown-profiles :int32)   ; BOOL
  (p-reserved :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WcmSetProfileList = Win32::API::More->new('wcmapi',
    'DWORD WcmSetProfileList(LPVOID pProfileList, DWORD dwPosition, BOOL fIgnoreUnknownProfiles, LPVOID pReserved)');
# my $ret = $WcmSetProfileList->Call($pProfileList, $dwPosition, $fIgnoreUnknownProfiles, $pReserved);
# pProfileList : WCM_PROFILE_INFO_LIST* -> LPVOID
# dwPosition : DWORD -> DWORD
# fIgnoreUnknownProfiles : BOOL -> BOOL
# pReserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型