ホーム › System.WindowsProgramming › LaunchINFSectionExW
LaunchINFSectionExW
関数INFセクションを拡張オプション付きで実行する(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT LaunchINFSectionExW(
HWND hwnd, // optional
HINSTANCE hInstance, // optional
LPWSTR pszParms,
INT nShow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | inoptional | UIの親となるウィンドウのハンドル。NULL可。 |
| hInstance | HINSTANCE | inoptional | 呼び出し元モジュールのインスタンスハンドル。 |
| pszParms | LPWSTR | in | INFファイル名やセクション等を含むカンマ区切りのパラメーター文字列。 |
| nShow | INT | in | ウィンドウの表示状態を指定するSW_系の値。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT LaunchINFSectionExW(
HWND hwnd, // optional
HINSTANCE hInstance, // optional
LPWSTR pszParms,
INT nShow
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int LaunchINFSectionExW(
IntPtr hwnd, // HWND optional
IntPtr hInstance, // HINSTANCE optional
[MarshalAs(UnmanagedType.LPWStr)] string pszParms, // LPWSTR
int nShow // INT
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function LaunchINFSectionExW(
hwnd As IntPtr, ' HWND optional
hInstance As IntPtr, ' HINSTANCE optional
<MarshalAs(UnmanagedType.LPWStr)> pszParms As String, ' LPWSTR
nShow As Integer ' INT
) As Integer
End Function' hwnd : HWND optional
' hInstance : HINSTANCE optional
' pszParms : LPWSTR
' nShow : INT
Declare PtrSafe Function LaunchINFSectionExW Lib "advpack" ( _
ByVal hwnd As LongPtr, _
ByVal hInstance As LongPtr, _
ByVal pszParms As LongPtr, _
ByVal nShow As Long) 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
LaunchINFSectionExW = ctypes.windll.advpack.LaunchINFSectionExW
LaunchINFSectionExW.restype = ctypes.c_int
LaunchINFSectionExW.argtypes = [
wintypes.HANDLE, # hwnd : HWND optional
wintypes.HANDLE, # hInstance : HINSTANCE optional
wintypes.LPCWSTR, # pszParms : LPWSTR
ctypes.c_int, # nShow : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
LaunchINFSectionExW = Fiddle::Function.new(
lib['LaunchINFSectionExW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
Fiddle::TYPE_VOIDP, # pszParms : LPWSTR
Fiddle::TYPE_INT, # nShow : INT
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn LaunchINFSectionExW(
hwnd: *mut core::ffi::c_void, // HWND optional
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
pszParms: *mut u16, // LPWSTR
nShow: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int LaunchINFSectionExW(IntPtr hwnd, IntPtr hInstance, [MarshalAs(UnmanagedType.LPWStr)] string pszParms, int nShow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_LaunchINFSectionExW' -Namespace Win32 -PassThru
# $api::LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)#uselib "ADVPACK.dll"
#func global LaunchINFSectionExW "LaunchINFSectionExW" wptr, wptr, wptr, wptr
; LaunchINFSectionExW hwnd, hInstance, pszParms, nShow ; 戻り値は stat
; hwnd : HWND optional -> "wptr"
; hInstance : HINSTANCE optional -> "wptr"
; pszParms : LPWSTR -> "wptr"
; nShow : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global LaunchINFSectionExW "LaunchINFSectionExW" sptr, sptr, wstr, int
; res = LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
; hwnd : HWND optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; pszParms : LPWSTR -> "wstr"
; nShow : INT -> "int"; HRESULT LaunchINFSectionExW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow)
#uselib "ADVPACK.dll"
#cfunc global LaunchINFSectionExW "LaunchINFSectionExW" intptr, intptr, wstr, int
; res = LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
; hwnd : HWND optional -> "intptr"
; hInstance : HINSTANCE optional -> "intptr"
; pszParms : LPWSTR -> "wstr"
; nShow : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procLaunchINFSectionExW = advpack.NewProc("LaunchINFSectionExW")
)
// hwnd (HWND optional), hInstance (HINSTANCE optional), pszParms (LPWSTR), nShow (INT)
r1, _, err := procLaunchINFSectionExW.Call(
uintptr(hwnd),
uintptr(hInstance),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszParms))),
uintptr(nShow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction LaunchINFSectionExW(
hwnd: THandle; // HWND optional
hInstance: THandle; // HINSTANCE optional
pszParms: PWideChar; // LPWSTR
nShow: Integer // INT
): Integer; stdcall;
external 'ADVPACK.dll' name 'LaunchINFSectionExW';result := DllCall("ADVPACK\LaunchINFSectionExW"
, "Ptr", hwnd ; HWND optional
, "Ptr", hInstance ; HINSTANCE optional
, "WStr", pszParms ; LPWSTR
, "Int", nShow ; INT
, "Int") ; return: HRESULT●LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow) = DLL("ADVPACK.dll", "int LaunchINFSectionExW(void*, void*, char*, int)")
# 呼び出し: LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
# hwnd : HWND optional -> "void*"
# hInstance : HINSTANCE optional -> "void*"
# pszParms : LPWSTR -> "char*"
# nShow : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "advpack" fn LaunchINFSectionExW(
hwnd: ?*anyopaque, // HWND optional
hInstance: ?*anyopaque, // HINSTANCE optional
pszParms: [*c]const u16, // LPWSTR
nShow: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc LaunchINFSectionExW(
hwnd: pointer, # HWND optional
hInstance: pointer, # HINSTANCE optional
pszParms: WideCString, # LPWSTR
nShow: int32 # INT
): int32 {.importc: "LaunchINFSectionExW", stdcall, dynlib: "ADVPACK.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "advpack");
extern(Windows)
int LaunchINFSectionExW(
void* hwnd, // HWND optional
void* hInstance, // HINSTANCE optional
const(wchar)* pszParms, // LPWSTR
int nShow // INT
);ccall((:LaunchINFSectionExW, "ADVPACK.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, Int32),
hwnd, hInstance, pszParms, nShow)
# hwnd : HWND optional -> Ptr{Cvoid}
# hInstance : HINSTANCE optional -> Ptr{Cvoid}
# pszParms : LPWSTR -> Cwstring
# nShow : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t LaunchINFSectionExW(
void* hwnd,
void* hInstance,
const uint16_t* pszParms,
int32_t nShow);
]]
local advpack = ffi.load("advpack")
-- advpack.LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
-- hwnd : HWND optional
-- hInstance : HINSTANCE optional
-- pszParms : LPWSTR
-- nShow : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const LaunchINFSectionExW = lib.func('__stdcall', 'LaunchINFSectionExW', 'int32_t', ['void *', 'void *', 'str16', 'int32_t']);
// LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
// hwnd : HWND optional -> 'void *'
// hInstance : HINSTANCE optional -> 'void *'
// pszParms : LPWSTR -> 'str16'
// nShow : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVPACK.dll", {
LaunchINFSectionExW: { parameters: ["pointer", "pointer", "buffer", "i32"], result: "i32" },
});
// lib.symbols.LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow)
// hwnd : HWND optional -> "pointer"
// hInstance : HINSTANCE optional -> "pointer"
// pszParms : LPWSTR -> "buffer"
// nShow : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t LaunchINFSectionExW(
void* hwnd,
void* hInstance,
const uint16_t* pszParms,
int32_t nShow);
C, "ADVPACK.dll");
// $ffi->LaunchINFSectionExW(hwnd, hInstance, pszParms, nShow);
// hwnd : HWND optional
// hInstance : HINSTANCE optional
// pszParms : LPWSTR
// nShow : INT
// 構造体/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 Advpack extends StdCallLibrary {
Advpack INSTANCE = Native.load("advpack", Advpack.class, W32APIOptions.UNICODE_OPTIONS);
int LaunchINFSectionExW(
Pointer hwnd, // HWND optional
Pointer hInstance, // HINSTANCE optional
WString pszParms, // LPWSTR
int nShow // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("advpack")]
lib LibADVPACK
fun LaunchINFSectionExW = LaunchINFSectionExW(
hwnd : Void*, # HWND optional
hInstance : Void*, # HINSTANCE optional
pszParms : UInt16*, # LPWSTR
nShow : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef LaunchINFSectionExWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Int32);
typedef LaunchINFSectionExWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, int);
final LaunchINFSectionExW = DynamicLibrary.open('ADVPACK.dll')
.lookupFunction<LaunchINFSectionExWNative, LaunchINFSectionExWDart>('LaunchINFSectionExW');
// hwnd : HWND optional -> Pointer<Void>
// hInstance : HINSTANCE optional -> Pointer<Void>
// pszParms : LPWSTR -> Pointer<Utf16>
// nShow : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LaunchINFSectionExW(
hwnd: THandle; // HWND optional
hInstance: THandle; // HINSTANCE optional
pszParms: PWideChar; // LPWSTR
nShow: Integer // INT
): Integer; stdcall;
external 'ADVPACK.dll' name 'LaunchINFSectionExW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "LaunchINFSectionExW"
c_LaunchINFSectionExW :: Ptr () -> Ptr () -> CWString -> Int32 -> IO Int32
-- hwnd : HWND optional -> Ptr ()
-- hInstance : HINSTANCE optional -> Ptr ()
-- pszParms : LPWSTR -> CWString
-- nShow : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let launchinfsectionexw =
foreign "LaunchINFSectionExW"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* hwnd : HWND optional -> (ptr void) *)
(* hInstance : HINSTANCE optional -> (ptr void) *)
(* pszParms : LPWSTR -> (ptr uint16_t) *)
(* nShow : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advpack (t "ADVPACK.dll"))
(cffi:use-foreign-library advpack)
(cffi:defcfun ("LaunchINFSectionExW" launch-infsection-ex-w :convention :stdcall) :int32
(hwnd :pointer) ; HWND optional
(h-instance :pointer) ; HINSTANCE optional
(psz-parms (:string :encoding :utf-16le)) ; LPWSTR
(n-show :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LaunchINFSectionExW = Win32::API::More->new('ADVPACK',
'int LaunchINFSectionExW(HANDLE hwnd, HANDLE hInstance, LPCWSTR pszParms, int nShow)');
# my $ret = $LaunchINFSectionExW->Call($hwnd, $hInstance, $pszParms, $nShow);
# hwnd : HWND optional -> HANDLE
# hInstance : HINSTANCE optional -> HANDLE
# pszParms : LPWSTR -> LPCWSTR
# nShow : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
類似 API
- f LaunchINFSectionW — INFセクションを起動して実行する(Unicode版)。