Win32 API 日本語リファレンス
ホームUI.Shell › WhichPlatform

WhichPlatform

関数
実行環境のシェルプラットフォーム種別を取得する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD WhichPlatform(void);

パラメーターなし。戻り値: DWORD

公式ドキュメント

WhichPlatform は変更される、または利用できなくなる可能性があります。

戻り値

型: UINT

戻り値 説明
PLATFORM_UNKNOWN
関数が Shell32.dll のバージョンを特定できませんでした。
PLATFORM_IE3
廃止予定: PLATFORM_BROWSERONLY を使用してください。
PLATFORM_BROWSERONLY
Shell32.dll のバージョンはブラウザー専用であり、新しいシェルは含まれていません。
PLATFORM_INTEGRATED
プラットフォームには統合されたシェルが含まれています。

解説(Remarks)

Windows XP には統合されたシェルが付属しているため、この関数は常に PLATFORM_INTEGRATED を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

WhichPlatform = ctypes.windll.shlwapi.WhichPlatform
WhichPlatform.restype = wintypes.DWORD
WhichPlatform.argtypes = []
require 'fiddle'
require 'fiddle/import'

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

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procWhichPlatform = shlwapi.NewProc("WhichPlatform")
)

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

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

typedef WhichPlatformNative = Uint32 Function();
typedef WhichPlatformDart = int Function();
final WhichPlatform = DynamicLibrary.open('SHLWAPI.dll')
    .lookupFunction<WhichPlatformNative, WhichPlatformDart>('WhichPlatform');
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WhichPlatform: DWORD; stdcall;
  external 'SHLWAPI.dll' name 'WhichPlatform';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WhichPlatform"
  c_WhichPlatform :: IO Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whichplatform =
  foreign "WhichPlatform"
    (void @-> returning uint32_t)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shlwapi (t "SHLWAPI.dll"))
(cffi:use-foreign-library shlwapi)

(cffi:defcfun ("WhichPlatform" which-platform :convention :stdcall) :uint32)
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WhichPlatform = Win32::API::More->new('SHLWAPI',
    'DWORD WhichPlatform()');
# my $ret = $WhichPlatform->Call();
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。