Win32 API 日本語リファレンス
ホームNetworking.Clustering › RegisterAppInstanceVersion

RegisterAppInstanceVersion

関数
アプリインスタンスのバージョン番号を登録する。
DLLNTLANMAN.dll呼出規約winapi

シグネチャ

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

DWORD RegisterAppInstanceVersion(
    GUID* AppInstanceId,
    ULONGLONG InstanceVersionHigh,
    ULONGLONG InstanceVersionLow
);

パラメーター

名前方向説明
AppInstanceIdGUID*inバージョンを登録する対象アプリインスタンス識別子(GUID)へのポインター。
InstanceVersionHighULONGLONGinインスタンスバージョン番号の上位64ビット。
InstanceVersionLowULONGLONGinインスタンスバージョン番号の下位64ビット。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RegisterAppInstanceVersion(
    GUID* AppInstanceId,
    ULONGLONG InstanceVersionHigh,
    ULONGLONG InstanceVersionLow
);
[DllImport("NTLANMAN.dll", ExactSpelling = true)]
static extern uint RegisterAppInstanceVersion(
    ref Guid AppInstanceId,   // GUID*
    ulong InstanceVersionHigh,   // ULONGLONG
    ulong InstanceVersionLow   // ULONGLONG
);
<DllImport("NTLANMAN.dll", ExactSpelling:=True)>
Public Shared Function RegisterAppInstanceVersion(
    ByRef AppInstanceId As Guid,   ' GUID*
    InstanceVersionHigh As ULong,   ' ULONGLONG
    InstanceVersionLow As ULong   ' ULONGLONG
) As UInteger
End Function
' AppInstanceId : GUID*
' InstanceVersionHigh : ULONGLONG
' InstanceVersionLow : ULONGLONG
Declare PtrSafe Function RegisterAppInstanceVersion Lib "ntlanman" ( _
    ByVal AppInstanceId As LongPtr, _
    ByVal InstanceVersionHigh As LongLong, _
    ByVal InstanceVersionLow As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegisterAppInstanceVersion = ctypes.windll.ntlanman.RegisterAppInstanceVersion
RegisterAppInstanceVersion.restype = wintypes.DWORD
RegisterAppInstanceVersion.argtypes = [
    ctypes.c_void_p,  # AppInstanceId : GUID*
    ctypes.c_ulonglong,  # InstanceVersionHigh : ULONGLONG
    ctypes.c_ulonglong,  # InstanceVersionLow : ULONGLONG
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NTLANMAN.dll')
RegisterAppInstanceVersion = Fiddle::Function.new(
  lib['RegisterAppInstanceVersion'],
  [
    Fiddle::TYPE_VOIDP,  # AppInstanceId : GUID*
    -Fiddle::TYPE_LONG_LONG,  # InstanceVersionHigh : ULONGLONG
    -Fiddle::TYPE_LONG_LONG,  # InstanceVersionLow : ULONGLONG
  ],
  -Fiddle::TYPE_INT)
#[link(name = "ntlanman")]
extern "system" {
    fn RegisterAppInstanceVersion(
        AppInstanceId: *mut GUID,  // GUID*
        InstanceVersionHigh: u64,  // ULONGLONG
        InstanceVersionLow: u64  // ULONGLONG
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NTLANMAN.dll")]
public static extern uint RegisterAppInstanceVersion(ref Guid AppInstanceId, ulong InstanceVersionHigh, ulong InstanceVersionLow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTLANMAN_RegisterAppInstanceVersion' -Namespace Win32 -PassThru
# $api::RegisterAppInstanceVersion(AppInstanceId, InstanceVersionHigh, InstanceVersionLow)
#uselib "NTLANMAN.dll"
#func global RegisterAppInstanceVersion "RegisterAppInstanceVersion" sptr, sptr, sptr
; RegisterAppInstanceVersion varptr(AppInstanceId), InstanceVersionHigh, InstanceVersionLow   ; 戻り値は stat
; AppInstanceId : GUID* -> "sptr"
; InstanceVersionHigh : ULONGLONG -> "sptr"
; InstanceVersionLow : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NTLANMAN.dll"
#cfunc global RegisterAppInstanceVersion "RegisterAppInstanceVersion" var, int64, int64
; res = RegisterAppInstanceVersion(AppInstanceId, InstanceVersionHigh, InstanceVersionLow)
; AppInstanceId : GUID* -> "var"
; InstanceVersionHigh : ULONGLONG -> "int64"
; InstanceVersionLow : ULONGLONG -> "int64"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD RegisterAppInstanceVersion(GUID* AppInstanceId, ULONGLONG InstanceVersionHigh, ULONGLONG InstanceVersionLow)
#uselib "NTLANMAN.dll"
#cfunc global RegisterAppInstanceVersion "RegisterAppInstanceVersion" var, int64, int64
; res = RegisterAppInstanceVersion(AppInstanceId, InstanceVersionHigh, InstanceVersionLow)
; AppInstanceId : GUID* -> "var"
; InstanceVersionHigh : ULONGLONG -> "int64"
; InstanceVersionLow : ULONGLONG -> "int64"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntlanman = windows.NewLazySystemDLL("NTLANMAN.dll")
	procRegisterAppInstanceVersion = ntlanman.NewProc("RegisterAppInstanceVersion")
)

// AppInstanceId (GUID*), InstanceVersionHigh (ULONGLONG), InstanceVersionLow (ULONGLONG)
r1, _, err := procRegisterAppInstanceVersion.Call(
	uintptr(AppInstanceId),
	uintptr(InstanceVersionHigh),
	uintptr(InstanceVersionLow),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RegisterAppInstanceVersion(
  AppInstanceId: PGUID;   // GUID*
  InstanceVersionHigh: UInt64;   // ULONGLONG
  InstanceVersionLow: UInt64   // ULONGLONG
): DWORD; stdcall;
  external 'NTLANMAN.dll' name 'RegisterAppInstanceVersion';
result := DllCall("NTLANMAN\RegisterAppInstanceVersion"
    , "Ptr", AppInstanceId   ; GUID*
    , "Int64", InstanceVersionHigh   ; ULONGLONG
    , "Int64", InstanceVersionLow   ; ULONGLONG
    , "UInt")   ; return: DWORD
●RegisterAppInstanceVersion(AppInstanceId, InstanceVersionHigh, InstanceVersionLow) = DLL("NTLANMAN.dll", "dword RegisterAppInstanceVersion(void*, qword, qword)")
# 呼び出し: RegisterAppInstanceVersion(AppInstanceId, InstanceVersionHigh, InstanceVersionLow)
# AppInstanceId : GUID* -> "void*"
# InstanceVersionHigh : ULONGLONG -> "qword"
# InstanceVersionLow : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef RegisterAppInstanceVersionNative = Uint32 Function(Pointer<Void>, Uint64, Uint64);
typedef RegisterAppInstanceVersionDart = int Function(Pointer<Void>, int, int);
final RegisterAppInstanceVersion = DynamicLibrary.open('NTLANMAN.dll')
    .lookupFunction<RegisterAppInstanceVersionNative, RegisterAppInstanceVersionDart>('RegisterAppInstanceVersion');
// AppInstanceId : GUID* -> Pointer<Void>
// InstanceVersionHigh : ULONGLONG -> Uint64
// InstanceVersionLow : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RegisterAppInstanceVersion(
  AppInstanceId: PGUID;   // GUID*
  InstanceVersionHigh: UInt64;   // ULONGLONG
  InstanceVersionLow: UInt64   // ULONGLONG
): DWORD; stdcall;
  external 'NTLANMAN.dll' name 'RegisterAppInstanceVersion';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RegisterAppInstanceVersion"
  c_RegisterAppInstanceVersion :: Ptr () -> Word64 -> Word64 -> IO Word32
-- AppInstanceId : GUID* -> Ptr ()
-- InstanceVersionHigh : ULONGLONG -> Word64
-- InstanceVersionLow : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let registerappinstanceversion =
  foreign "RegisterAppInstanceVersion"
    ((ptr void) @-> uint64_t @-> uint64_t @-> returning uint32_t)
(* AppInstanceId : GUID* -> (ptr void) *)
(* InstanceVersionHigh : ULONGLONG -> uint64_t *)
(* InstanceVersionLow : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ntlanman (t "NTLANMAN.dll"))
(cffi:use-foreign-library ntlanman)

(cffi:defcfun ("RegisterAppInstanceVersion" register-app-instance-version :convention :stdcall) :uint32
  (app-instance-id :pointer)   ; GUID*
  (instance-version-high :uint64)   ; ULONGLONG
  (instance-version-low :uint64))   ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RegisterAppInstanceVersion = Win32::API::More->new('NTLANMAN',
    'DWORD RegisterAppInstanceVersion(LPVOID AppInstanceId, UINT64 InstanceVersionHigh, UINT64 InstanceVersionLow)');
# my $ret = $RegisterAppInstanceVersion->Call($AppInstanceId, $InstanceVersionHigh, $InstanceVersionLow);
# AppInstanceId : GUID* -> LPVOID
# InstanceVersionHigh : ULONGLONG -> UINT64
# InstanceVersionLow : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。