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

GetSharedServiceDirectory

関数
共有サービスのディレクトリパスを取得する。
DLLapi-ms-win-service-core-l1-1-5.dll呼出規約winapi

シグネチャ

// api-ms-win-service-core-l1-1-5.dll
#include <windows.h>

DWORD GetSharedServiceDirectory(
    SC_HANDLE ServiceHandle,
    SERVICE_SHARED_DIRECTORY_TYPE DirectoryType,
    LPWSTR PathBuffer,   // optional
    DWORD PathBufferLength,
    DWORD* RequiredBufferLength
);

パラメーター

名前方向説明
ServiceHandleSC_HANDLEinサービスへのハンドル。このハンドルは OpenService 関数によって返されます。
DirectoryTypeSERVICE_SHARED_DIRECTORY_TYPEin取得するサービスごとの共有ディレクトリパスの種類を識別する SERVICE_SHARED_DIRECTORY_TYPE 列挙体のメンバー。
PathBufferLPWSTRoutoptionalパス文字列のコピー先となる、呼び出し側が割り当てたバッファー。NULL の場合、関数呼び出しは ERROR_INSUFFICIENT_BUFFER で失敗し、必要なバッファー長を WCHAR 単位で RequiredBufferLength に返します。NULL でない場合は、バッファーの長さを PathBufferLength に指定してください。パスは書き込まれる場合、NULL で終端されます。
PathBufferLengthDWORDinPathBuffer で指定したバッファーの長さ(WCHAR 単位)。PathBuffer が NULL の場合、この引数は無視されます。
RequiredBufferLengthDWORD*outこの値には、必要なバッファー長が WCHAR 単位で設定されます。この長さには終端の NULL 文字が含まれます。

戻り値の型: DWORD

公式ドキュメント

サービスおよび関連プログラムが状態を読み書きするための、サービスごとのファイルシステム上の場所のパスを返します。

戻り値

すべての操作が正常に完了し、NULL 終端の状態パスが PathBuffer に書き込まれた場合は ERROR_SUCCESS を返します。PathBuffer が状態パスを格納するのに十分な大きさでなかった場合、または PathBuffer が NULL であった場合は ERROR_INSUFFICIENT_BUFFER を返します。この場合、必要なバッファー長が WCHAR 単位で RequiredBufferLength を介して返されます。その他の失敗が発生した場合は、Win32 エラーコードが返されます。

解説(Remarks)

ServiceSharedDirectoryPersistentState の場合、ディレクトリのセキュリティは、ローカルシステムアカウント、サービス SID、およびローカル管理者にのみ書き込みアクセスを許可するように設定されます。この API を呼び出すサービスでは、必ずサービス SID を有効にしてください。詳細については、SERVICE_SID_INFO を参照してください。

サービス自身による使用専用にサービス状態を提供する類似の API については、GetServiceDirectory を参照してください。

すべてのサービス状態ディレクトリは、サービスがアンインストールされると、サービスコントロールマネージャーによって削除されます。

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

各言語での呼び出し定義

// api-ms-win-service-core-l1-1-5.dll
#include <windows.h>

DWORD GetSharedServiceDirectory(
    SC_HANDLE ServiceHandle,
    SERVICE_SHARED_DIRECTORY_TYPE DirectoryType,
    LPWSTR PathBuffer,   // optional
    DWORD PathBufferLength,
    DWORD* RequiredBufferLength
);
[DllImport("api-ms-win-service-core-l1-1-5.dll", ExactSpelling = true)]
static extern uint GetSharedServiceDirectory(
    IntPtr ServiceHandle,   // SC_HANDLE
    int DirectoryType,   // SERVICE_SHARED_DIRECTORY_TYPE
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer,   // LPWSTR optional, out
    uint PathBufferLength,   // DWORD
    out uint RequiredBufferLength   // DWORD* out
);
<DllImport("api-ms-win-service-core-l1-1-5.dll", ExactSpelling:=True)>
Public Shared Function GetSharedServiceDirectory(
    ServiceHandle As IntPtr,   ' SC_HANDLE
    DirectoryType As Integer,   ' SERVICE_SHARED_DIRECTORY_TYPE
    <MarshalAs(UnmanagedType.LPWStr)> PathBuffer As System.Text.StringBuilder,   ' LPWSTR optional, out
    PathBufferLength As UInteger,   ' DWORD
    <Out> ByRef RequiredBufferLength As UInteger   ' DWORD* out
) As UInteger
End Function
' ServiceHandle : SC_HANDLE
' DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE
' PathBuffer : LPWSTR optional, out
' PathBufferLength : DWORD
' RequiredBufferLength : DWORD* out
Declare PtrSafe Function GetSharedServiceDirectory Lib "api-ms-win-service-core-l1-1-5" ( _
    ByVal ServiceHandle As LongPtr, _
    ByVal DirectoryType As Long, _
    ByVal PathBuffer As LongPtr, _
    ByVal PathBufferLength As Long, _
    ByRef RequiredBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetSharedServiceDirectory = ctypes.windll.LoadLibrary("api-ms-win-service-core-l1-1-5.dll").GetSharedServiceDirectory
GetSharedServiceDirectory.restype = wintypes.DWORD
GetSharedServiceDirectory.argtypes = [
    wintypes.HANDLE,  # ServiceHandle : SC_HANDLE
    ctypes.c_int,  # DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE
    wintypes.LPWSTR,  # PathBuffer : LPWSTR optional, out
    wintypes.DWORD,  # PathBufferLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # RequiredBufferLength : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-service-core-l1-1-5.dll')
GetSharedServiceDirectory = Fiddle::Function.new(
  lib['GetSharedServiceDirectory'],
  [
    Fiddle::TYPE_VOIDP,  # ServiceHandle : SC_HANDLE
    Fiddle::TYPE_INT,  # DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE
    Fiddle::TYPE_VOIDP,  # PathBuffer : LPWSTR optional, out
    -Fiddle::TYPE_INT,  # PathBufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # RequiredBufferLength : DWORD* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "api-ms-win-service-core-l1-1-5")]
extern "system" {
    fn GetSharedServiceDirectory(
        ServiceHandle: *mut core::ffi::c_void,  // SC_HANDLE
        DirectoryType: i32,  // SERVICE_SHARED_DIRECTORY_TYPE
        PathBuffer: *mut u16,  // LPWSTR optional, out
        PathBufferLength: u32,  // DWORD
        RequiredBufferLength: *mut u32  // DWORD* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-service-core-l1-1-5.dll")]
public static extern uint GetSharedServiceDirectory(IntPtr ServiceHandle, int DirectoryType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer, uint PathBufferLength, out uint RequiredBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-service-core-l1-1-5_GetSharedServiceDirectory' -Namespace Win32 -PassThru
# $api::GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
#uselib "api-ms-win-service-core-l1-1-5.dll"
#func global GetSharedServiceDirectory "GetSharedServiceDirectory" sptr, sptr, sptr, sptr, sptr
; GetSharedServiceDirectory ServiceHandle, DirectoryType, varptr(PathBuffer), PathBufferLength, varptr(RequiredBufferLength)   ; 戻り値は stat
; ServiceHandle : SC_HANDLE -> "sptr"
; DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "sptr"
; PathBuffer : LPWSTR optional, out -> "sptr"
; PathBufferLength : DWORD -> "sptr"
; RequiredBufferLength : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-service-core-l1-1-5.dll"
#cfunc global GetSharedServiceDirectory "GetSharedServiceDirectory" sptr, int, var, int, var
; res = GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
; ServiceHandle : SC_HANDLE -> "sptr"
; DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "int"
; PathBuffer : LPWSTR optional, out -> "var"
; PathBufferLength : DWORD -> "int"
; RequiredBufferLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetSharedServiceDirectory(SC_HANDLE ServiceHandle, SERVICE_SHARED_DIRECTORY_TYPE DirectoryType, LPWSTR PathBuffer, DWORD PathBufferLength, DWORD* RequiredBufferLength)
#uselib "api-ms-win-service-core-l1-1-5.dll"
#cfunc global GetSharedServiceDirectory "GetSharedServiceDirectory" intptr, int, var, int, var
; res = GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
; ServiceHandle : SC_HANDLE -> "intptr"
; DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "int"
; PathBuffer : LPWSTR optional, out -> "var"
; PathBufferLength : DWORD -> "int"
; RequiredBufferLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_service_core_l1_1_5 = windows.NewLazySystemDLL("api-ms-win-service-core-l1-1-5.dll")
	procGetSharedServiceDirectory = api_ms_win_service_core_l1_1_5.NewProc("GetSharedServiceDirectory")
)

// ServiceHandle (SC_HANDLE), DirectoryType (SERVICE_SHARED_DIRECTORY_TYPE), PathBuffer (LPWSTR optional, out), PathBufferLength (DWORD), RequiredBufferLength (DWORD* out)
r1, _, err := procGetSharedServiceDirectory.Call(
	uintptr(ServiceHandle),
	uintptr(DirectoryType),
	uintptr(PathBuffer),
	uintptr(PathBufferLength),
	uintptr(RequiredBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetSharedServiceDirectory(
  ServiceHandle: THandle;   // SC_HANDLE
  DirectoryType: Integer;   // SERVICE_SHARED_DIRECTORY_TYPE
  PathBuffer: PWideChar;   // LPWSTR optional, out
  PathBufferLength: DWORD;   // DWORD
  RequiredBufferLength: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'api-ms-win-service-core-l1-1-5.dll' name 'GetSharedServiceDirectory';
result := DllCall("api-ms-win-service-core-l1-1-5\GetSharedServiceDirectory"
    , "Ptr", ServiceHandle   ; SC_HANDLE
    , "Int", DirectoryType   ; SERVICE_SHARED_DIRECTORY_TYPE
    , "Ptr", PathBuffer   ; LPWSTR optional, out
    , "UInt", PathBufferLength   ; DWORD
    , "Ptr", RequiredBufferLength   ; DWORD* out
    , "UInt")   ; return: DWORD
●GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength) = DLL("api-ms-win-service-core-l1-1-5.dll", "dword GetSharedServiceDirectory(void*, int, char*, dword, void*)")
# 呼び出し: GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
# ServiceHandle : SC_HANDLE -> "void*"
# DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "int"
# PathBuffer : LPWSTR optional, out -> "char*"
# PathBufferLength : DWORD -> "dword"
# RequiredBufferLength : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "api-ms-win-service-core-l1-1-5" fn GetSharedServiceDirectory(
    ServiceHandle: ?*anyopaque, // SC_HANDLE
    DirectoryType: i32, // SERVICE_SHARED_DIRECTORY_TYPE
    PathBuffer: [*c]u16, // LPWSTR optional, out
    PathBufferLength: u32, // DWORD
    RequiredBufferLength: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) u32;
proc GetSharedServiceDirectory(
    ServiceHandle: pointer,  # SC_HANDLE
    DirectoryType: int32,  # SERVICE_SHARED_DIRECTORY_TYPE
    PathBuffer: ptr uint16,  # LPWSTR optional, out
    PathBufferLength: uint32,  # DWORD
    RequiredBufferLength: ptr uint32  # DWORD* out
): uint32 {.importc: "GetSharedServiceDirectory", stdcall, dynlib: "api-ms-win-service-core-l1-1-5.dll".}
pragma(lib, "api-ms-win-service-core-l1-1-5");
extern(Windows)
uint GetSharedServiceDirectory(
    void* ServiceHandle,   // SC_HANDLE
    int DirectoryType,   // SERVICE_SHARED_DIRECTORY_TYPE
    wchar* PathBuffer,   // LPWSTR optional, out
    uint PathBufferLength,   // DWORD
    uint* RequiredBufferLength   // DWORD* out
);
ccall((:GetSharedServiceDirectory, "api-ms-win-service-core-l1-1-5.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Int32, Ptr{UInt16}, UInt32, Ptr{UInt32}),
      ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
# ServiceHandle : SC_HANDLE -> Ptr{Cvoid}
# DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> Int32
# PathBuffer : LPWSTR optional, out -> Ptr{UInt16}
# PathBufferLength : DWORD -> UInt32
# RequiredBufferLength : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t GetSharedServiceDirectory(
    void* ServiceHandle,
    int32_t DirectoryType,
    uint16_t* PathBuffer,
    uint32_t PathBufferLength,
    uint32_t* RequiredBufferLength);
]]
local api-ms-win-service-core-l1-1-5 = ffi.load("api-ms-win-service-core-l1-1-5")
-- api-ms-win-service-core-l1-1-5.GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
-- ServiceHandle : SC_HANDLE
-- DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE
-- PathBuffer : LPWSTR optional, out
-- PathBufferLength : DWORD
-- RequiredBufferLength : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('api-ms-win-service-core-l1-1-5.dll');
const GetSharedServiceDirectory = lib.func('__stdcall', 'GetSharedServiceDirectory', 'uint32_t', ['void *', 'int32_t', 'uint16_t *', 'uint32_t', 'uint32_t *']);
// GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
// ServiceHandle : SC_HANDLE -> 'void *'
// DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> 'int32_t'
// PathBuffer : LPWSTR optional, out -> 'uint16_t *'
// PathBufferLength : DWORD -> 'uint32_t'
// RequiredBufferLength : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("api-ms-win-service-core-l1-1-5.dll", {
  GetSharedServiceDirectory: { parameters: ["pointer", "i32", "buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength)
// ServiceHandle : SC_HANDLE -> "pointer"
// DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "i32"
// PathBuffer : LPWSTR optional, out -> "buffer"
// PathBufferLength : DWORD -> "u32"
// RequiredBufferLength : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t GetSharedServiceDirectory(
    void* ServiceHandle,
    int32_t DirectoryType,
    uint16_t* PathBuffer,
    uint32_t PathBufferLength,
    uint32_t* RequiredBufferLength);
C, "api-ms-win-service-core-l1-1-5.dll");
// $ffi->GetSharedServiceDirectory(ServiceHandle, DirectoryType, PathBuffer, PathBufferLength, RequiredBufferLength);
// ServiceHandle : SC_HANDLE
// DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE
// PathBuffer : LPWSTR optional, out
// PathBufferLength : DWORD
// RequiredBufferLength : DWORD* 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 Api-ms-win-service-core-l1-1-5 extends StdCallLibrary {
    Api-ms-win-service-core-l1-1-5 INSTANCE = Native.load("api-ms-win-service-core-l1-1-5", Api-ms-win-service-core-l1-1-5.class);
    int GetSharedServiceDirectory(
        Pointer ServiceHandle,   // SC_HANDLE
        int DirectoryType,   // SERVICE_SHARED_DIRECTORY_TYPE
        char[] PathBuffer,   // LPWSTR optional, out
        int PathBufferLength,   // DWORD
        IntByReference RequiredBufferLength   // DWORD* out
    );
}
@[Link("api-ms-win-service-core-l1-1-5")]
lib Libapi-ms-win-service-core-l1-1-5
  fun GetSharedServiceDirectory = GetSharedServiceDirectory(
    ServiceHandle : Void*,   # SC_HANDLE
    DirectoryType : Int32,   # SERVICE_SHARED_DIRECTORY_TYPE
    PathBuffer : UInt16*,   # LPWSTR optional, out
    PathBufferLength : UInt32,   # DWORD
    RequiredBufferLength : UInt32*   # DWORD* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetSharedServiceDirectoryNative = Uint32 Function(Pointer<Void>, Int32, Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef GetSharedServiceDirectoryDart = int Function(Pointer<Void>, int, Pointer<Utf16>, int, Pointer<Uint32>);
final GetSharedServiceDirectory = DynamicLibrary.open('api-ms-win-service-core-l1-1-5.dll')
    .lookupFunction<GetSharedServiceDirectoryNative, GetSharedServiceDirectoryDart>('GetSharedServiceDirectory');
// ServiceHandle : SC_HANDLE -> Pointer<Void>
// DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> Int32
// PathBuffer : LPWSTR optional, out -> Pointer<Utf16>
// PathBufferLength : DWORD -> Uint32
// RequiredBufferLength : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetSharedServiceDirectory(
  ServiceHandle: THandle;   // SC_HANDLE
  DirectoryType: Integer;   // SERVICE_SHARED_DIRECTORY_TYPE
  PathBuffer: PWideChar;   // LPWSTR optional, out
  PathBufferLength: DWORD;   // DWORD
  RequiredBufferLength: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'api-ms-win-service-core-l1-1-5.dll' name 'GetSharedServiceDirectory';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetSharedServiceDirectory"
  c_GetSharedServiceDirectory :: Ptr () -> Int32 -> CWString -> Word32 -> Ptr Word32 -> IO Word32
-- ServiceHandle : SC_HANDLE -> Ptr ()
-- DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> Int32
-- PathBuffer : LPWSTR optional, out -> CWString
-- PathBufferLength : DWORD -> Word32
-- RequiredBufferLength : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getsharedservicedirectory =
  foreign "GetSharedServiceDirectory"
    ((ptr void) @-> int32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning uint32_t)
(* ServiceHandle : SC_HANDLE -> (ptr void) *)
(* DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> int32_t *)
(* PathBuffer : LPWSTR optional, out -> (ptr uint16_t) *)
(* PathBufferLength : DWORD -> uint32_t *)
(* RequiredBufferLength : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library api-ms-win-service-core-l1-1-5 (t "api-ms-win-service-core-l1-1-5.dll"))
(cffi:use-foreign-library api-ms-win-service-core-l1-1-5)

(cffi:defcfun ("GetSharedServiceDirectory" get-shared-service-directory :convention :stdcall) :uint32
  (service-handle :pointer)   ; SC_HANDLE
  (directory-type :int32)   ; SERVICE_SHARED_DIRECTORY_TYPE
  (path-buffer :pointer)   ; LPWSTR optional, out
  (path-buffer-length :uint32)   ; DWORD
  (required-buffer-length :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetSharedServiceDirectory = Win32::API::More->new('api-ms-win-service-core-l1-1-5',
    'DWORD GetSharedServiceDirectory(HANDLE ServiceHandle, int DirectoryType, LPWSTR PathBuffer, DWORD PathBufferLength, LPVOID RequiredBufferLength)');
# my $ret = $GetSharedServiceDirectory->Call($ServiceHandle, $DirectoryType, $PathBuffer, $PathBufferLength, $RequiredBufferLength);
# ServiceHandle : SC_HANDLE -> HANDLE
# DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> int
# PathBuffer : LPWSTR optional, out -> LPWSTR
# PathBufferLength : DWORD -> DWORD
# RequiredBufferLength : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型