ホーム › System.Services › GetSharedServiceDirectory
GetSharedServiceDirectory
関数共有サービスのディレクトリパスを取得する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServiceHandle | SC_HANDLE | in |
| DirectoryType | SERVICE_SHARED_DIRECTORY_TYPE | in |
| PathBuffer | LPWSTR | outoptional |
| PathBufferLength | DWORD | in |
| RequiredBufferLength | DWORD* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "api-ms-win-service-core-l1-1-5.dll" #cfunc global GetSharedServiceDirectory "GetSharedServiceDirectory" sptr, int, sptr, int, sptr ; res = GetSharedServiceDirectory(ServiceHandle, DirectoryType, varptr(PathBuffer), PathBufferLength, varptr(RequiredBufferLength)) ; ServiceHandle : SC_HANDLE -> "sptr" ; DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "int" ; PathBuffer : LPWSTR optional, out -> "sptr" ; PathBufferLength : DWORD -> "int" ; RequiredBufferLength : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, intptr ; res = GetSharedServiceDirectory(ServiceHandle, DirectoryType, varptr(PathBuffer), PathBufferLength, varptr(RequiredBufferLength)) ; ServiceHandle : SC_HANDLE -> "intptr" ; DirectoryType : SERVICE_SHARED_DIRECTORY_TYPE -> "int" ; PathBuffer : LPWSTR optional, out -> "intptr" ; PathBufferLength : DWORD -> "int" ; RequiredBufferLength : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。