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