Win32 API 日本語リファレンス
ホームSystem.Threading › GetProcessVersion

GetProcessVersion

関数
指定プロセスが要求するシステムのバージョンを取得する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

DWORD GetProcessVersion(
    DWORD ProcessId
);

パラメーター

名前方向
ProcessIdDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetProcessVersion(
    DWORD ProcessId
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint GetProcessVersion(
    uint ProcessId   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetProcessVersion(
    ProcessId As UInteger   ' DWORD
) As UInteger
End Function
' ProcessId : DWORD
Declare PtrSafe Function GetProcessVersion Lib "kernel32" ( _
    ByVal ProcessId As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetProcessVersion = ctypes.windll.kernel32.GetProcessVersion
GetProcessVersion.restype = wintypes.DWORD
GetProcessVersion.argtypes = [
    wintypes.DWORD,  # ProcessId : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetProcessVersion = Fiddle::Function.new(
  lib['GetProcessVersion'],
  [
    -Fiddle::TYPE_INT,  # ProcessId : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetProcessVersion(
        ProcessId: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern uint GetProcessVersion(uint ProcessId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetProcessVersion' -Namespace Win32 -PassThru
# $api::GetProcessVersion(ProcessId)
#uselib "KERNEL32.dll"
#func global GetProcessVersion "GetProcessVersion" sptr
; GetProcessVersion ProcessId   ; 戻り値は stat
; ProcessId : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global GetProcessVersion "GetProcessVersion" int
; res = GetProcessVersion(ProcessId)
; ProcessId : DWORD -> "int"
; DWORD GetProcessVersion(DWORD ProcessId)
#uselib "KERNEL32.dll"
#cfunc global GetProcessVersion "GetProcessVersion" int
; res = GetProcessVersion(ProcessId)
; ProcessId : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetProcessVersion = kernel32.NewProc("GetProcessVersion")
)

// ProcessId (DWORD)
r1, _, err := procGetProcessVersion.Call(
	uintptr(ProcessId),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetProcessVersion(
  ProcessId: DWORD   // DWORD
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'GetProcessVersion';
result := DllCall("KERNEL32\GetProcessVersion"
    , "UInt", ProcessId   ; DWORD
    , "UInt")   ; return: DWORD
●GetProcessVersion(ProcessId) = DLL("KERNEL32.dll", "dword GetProcessVersion(dword)")
# 呼び出し: GetProcessVersion(ProcessId)
# ProcessId : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。