ホーム › Storage.Packaging.Appx › GetPackageFullName
GetPackageFullName
関数指定プロセスのパッケージフルネームを取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
WIN32_ERROR GetPackageFullName(
HANDLE hProcess,
DWORD* packageFullNameLength,
LPWSTR packageFullName // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hProcess | HANDLE | in | 対象プロセスのハンドル。PROCESS_QUERY_*権限が必要。 |
| packageFullNameLength | DWORD* | inout | 入力で文字数、出力で必要文字数を受け取る入出力ポインタ(終端含む)。 |
| packageFullName | LPWSTR | outoptional | 対象プロセスのパッケージフルネームを受け取る出力バッファ。NULLでサイズ照会可。 |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
WIN32_ERROR GetPackageFullName(
HANDLE hProcess,
DWORD* packageFullNameLength,
LPWSTR packageFullName // optional
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint GetPackageFullName(
IntPtr hProcess, // HANDLE
ref uint packageFullNameLength, // DWORD* in/out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder packageFullName // LPWSTR optional, out
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetPackageFullName(
hProcess As IntPtr, ' HANDLE
ByRef packageFullNameLength As UInteger, ' DWORD* in/out
<MarshalAs(UnmanagedType.LPWStr)> packageFullName As System.Text.StringBuilder ' LPWSTR optional, out
) As UInteger
End Function' hProcess : HANDLE
' packageFullNameLength : DWORD* in/out
' packageFullName : LPWSTR optional, out
Declare PtrSafe Function GetPackageFullName Lib "kernel32" ( _
ByVal hProcess As LongPtr, _
ByRef packageFullNameLength As Long, _
ByVal packageFullName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetPackageFullName = ctypes.windll.kernel32.GetPackageFullName
GetPackageFullName.restype = wintypes.DWORD
GetPackageFullName.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
ctypes.POINTER(wintypes.DWORD), # packageFullNameLength : DWORD* in/out
wintypes.LPWSTR, # packageFullName : LPWSTR optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetPackageFullName = Fiddle::Function.new(
lib['GetPackageFullName'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # packageFullNameLength : DWORD* in/out
Fiddle::TYPE_VOIDP, # packageFullName : LPWSTR optional, out
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetPackageFullName(
hProcess: *mut core::ffi::c_void, // HANDLE
packageFullNameLength: *mut u32, // DWORD* in/out
packageFullName: *mut u16 // LPWSTR optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint GetPackageFullName(IntPtr hProcess, ref uint packageFullNameLength, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder packageFullName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetPackageFullName' -Namespace Win32 -PassThru
# $api::GetPackageFullName(hProcess, packageFullNameLength, packageFullName)#uselib "KERNEL32.dll"
#func global GetPackageFullName "GetPackageFullName" sptr, sptr, sptr
; GetPackageFullName hProcess, varptr(packageFullNameLength), varptr(packageFullName) ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; packageFullNameLength : DWORD* in/out -> "sptr"
; packageFullName : LPWSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetPackageFullName "GetPackageFullName" sptr, var, var ; res = GetPackageFullName(hProcess, packageFullNameLength, packageFullName) ; hProcess : HANDLE -> "sptr" ; packageFullNameLength : DWORD* in/out -> "var" ; packageFullName : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetPackageFullName "GetPackageFullName" sptr, sptr, sptr ; res = GetPackageFullName(hProcess, varptr(packageFullNameLength), varptr(packageFullName)) ; hProcess : HANDLE -> "sptr" ; packageFullNameLength : DWORD* in/out -> "sptr" ; packageFullName : LPWSTR optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR GetPackageFullName(HANDLE hProcess, DWORD* packageFullNameLength, LPWSTR packageFullName) #uselib "KERNEL32.dll" #cfunc global GetPackageFullName "GetPackageFullName" intptr, var, var ; res = GetPackageFullName(hProcess, packageFullNameLength, packageFullName) ; hProcess : HANDLE -> "intptr" ; packageFullNameLength : DWORD* in/out -> "var" ; packageFullName : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR GetPackageFullName(HANDLE hProcess, DWORD* packageFullNameLength, LPWSTR packageFullName) #uselib "KERNEL32.dll" #cfunc global GetPackageFullName "GetPackageFullName" intptr, intptr, intptr ; res = GetPackageFullName(hProcess, varptr(packageFullNameLength), varptr(packageFullName)) ; hProcess : HANDLE -> "intptr" ; packageFullNameLength : DWORD* in/out -> "intptr" ; packageFullName : LPWSTR optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetPackageFullName = kernel32.NewProc("GetPackageFullName")
)
// hProcess (HANDLE), packageFullNameLength (DWORD* in/out), packageFullName (LPWSTR optional, out)
r1, _, err := procGetPackageFullName.Call(
uintptr(hProcess),
uintptr(packageFullNameLength),
uintptr(packageFullName),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction GetPackageFullName(
hProcess: THandle; // HANDLE
packageFullNameLength: Pointer; // DWORD* in/out
packageFullName: PWideChar // LPWSTR optional, out
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetPackageFullName';result := DllCall("KERNEL32\GetPackageFullName"
, "Ptr", hProcess ; HANDLE
, "Ptr", packageFullNameLength ; DWORD* in/out
, "Ptr", packageFullName ; LPWSTR optional, out
, "UInt") ; return: WIN32_ERROR●GetPackageFullName(hProcess, packageFullNameLength, packageFullName) = DLL("KERNEL32.dll", "dword GetPackageFullName(void*, void*, char*)")
# 呼び出し: GetPackageFullName(hProcess, packageFullNameLength, packageFullName)
# hProcess : HANDLE -> "void*"
# packageFullNameLength : DWORD* in/out -> "void*"
# packageFullName : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn GetPackageFullName(
hProcess: ?*anyopaque, // HANDLE
packageFullNameLength: [*c]u32, // DWORD* in/out
packageFullName: [*c]u16 // LPWSTR optional, out
) callconv(std.os.windows.WINAPI) u32;proc GetPackageFullName(
hProcess: pointer, # HANDLE
packageFullNameLength: ptr uint32, # DWORD* in/out
packageFullName: ptr uint16 # LPWSTR optional, out
): uint32 {.importc: "GetPackageFullName", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
uint GetPackageFullName(
void* hProcess, // HANDLE
uint* packageFullNameLength, // DWORD* in/out
wchar* packageFullName // LPWSTR optional, out
);ccall((:GetPackageFullName, "KERNEL32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{UInt32}, Ptr{UInt16}),
hProcess, packageFullNameLength, packageFullName)
# hProcess : HANDLE -> Ptr{Cvoid}
# packageFullNameLength : DWORD* in/out -> Ptr{UInt32}
# packageFullName : LPWSTR optional, out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetPackageFullName(
void* hProcess,
uint32_t* packageFullNameLength,
uint16_t* packageFullName);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.GetPackageFullName(hProcess, packageFullNameLength, packageFullName)
-- hProcess : HANDLE
-- packageFullNameLength : DWORD* in/out
-- packageFullName : LPWSTR optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const GetPackageFullName = lib.func('__stdcall', 'GetPackageFullName', 'uint32_t', ['void *', 'uint32_t *', 'uint16_t *']);
// GetPackageFullName(hProcess, packageFullNameLength, packageFullName)
// hProcess : HANDLE -> 'void *'
// packageFullNameLength : DWORD* in/out -> 'uint32_t *'
// packageFullName : LPWSTR optional, out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
GetPackageFullName: { parameters: ["pointer", "pointer", "buffer"], result: "u32" },
});
// lib.symbols.GetPackageFullName(hProcess, packageFullNameLength, packageFullName)
// hProcess : HANDLE -> "pointer"
// packageFullNameLength : DWORD* in/out -> "pointer"
// packageFullName : LPWSTR optional, out -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetPackageFullName(
void* hProcess,
uint32_t* packageFullNameLength,
uint16_t* packageFullName);
C, "KERNEL32.dll");
// $ffi->GetPackageFullName(hProcess, packageFullNameLength, packageFullName);
// hProcess : HANDLE
// packageFullNameLength : DWORD* in/out
// packageFullName : LPWSTR optional, out
// 構造体/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
int GetPackageFullName(
Pointer hProcess, // HANDLE
IntByReference packageFullNameLength, // DWORD* in/out
char[] packageFullName // LPWSTR optional, out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun GetPackageFullName = GetPackageFullName(
hProcess : Void*, # HANDLE
packageFullNameLength : UInt32*, # DWORD* in/out
packageFullName : UInt16* # LPWSTR optional, out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetPackageFullNameNative = Uint32 Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
typedef GetPackageFullNameDart = int Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
final GetPackageFullName = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<GetPackageFullNameNative, GetPackageFullNameDart>('GetPackageFullName');
// hProcess : HANDLE -> Pointer<Void>
// packageFullNameLength : DWORD* in/out -> Pointer<Uint32>
// packageFullName : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetPackageFullName(
hProcess: THandle; // HANDLE
packageFullNameLength: Pointer; // DWORD* in/out
packageFullName: PWideChar // LPWSTR optional, out
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetPackageFullName';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetPackageFullName"
c_GetPackageFullName :: Ptr () -> Ptr Word32 -> CWString -> IO Word32
-- hProcess : HANDLE -> Ptr ()
-- packageFullNameLength : DWORD* in/out -> Ptr Word32
-- packageFullName : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getpackagefullname =
foreign "GetPackageFullName"
((ptr void) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* hProcess : HANDLE -> (ptr void) *)
(* packageFullNameLength : DWORD* in/out -> (ptr uint32_t) *)
(* packageFullName : LPWSTR optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("GetPackageFullName" get-package-full-name :convention :stdcall) :uint32
(h-process :pointer) ; HANDLE
(package-full-name-length :pointer) ; DWORD* in/out
(package-full-name :pointer)) ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetPackageFullName = Win32::API::More->new('KERNEL32',
'DWORD GetPackageFullName(HANDLE hProcess, LPVOID packageFullNameLength, LPWSTR packageFullName)');
# my $ret = $GetPackageFullName->Call($hProcess, $packageFullNameLength, $packageFullName);
# hProcess : HANDLE -> HANDLE
# packageFullNameLength : DWORD* in/out -> LPVOID
# packageFullName : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型