Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › GetNetScheduleAccountInformation

GetNetScheduleAccountInformation

関数
タスクスケジューラの実行アカウント情報を取得する。
DLLmstask.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT GetNetScheduleAccountInformation(
    LPCWSTR pwszServerName,
    DWORD ccAccount,
    LPWSTR wszAccount
);

パラメーター

名前方向説明
pwszServerNameLPCWSTRin対象サーバー名を指定する。NULL可でローカルを対象とする。
ccAccountDWORDinwszAccountバッファの文字数(容量)を指定する。
wszAccountLPWSTRoutスケジュールサービスのアカウント名を受け取るバッファ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetNetScheduleAccountInformation(
    LPCWSTR pwszServerName,
    DWORD ccAccount,
    LPWSTR wszAccount
);
[DllImport("mstask.dll", ExactSpelling = true)]
static extern int GetNetScheduleAccountInformation(
    [MarshalAs(UnmanagedType.LPWStr)] string pwszServerName,   // LPCWSTR
    uint ccAccount,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszAccount   // LPWSTR out
);
<DllImport("mstask.dll", ExactSpelling:=True)>
Public Shared Function GetNetScheduleAccountInformation(
    <MarshalAs(UnmanagedType.LPWStr)> pwszServerName As String,   ' LPCWSTR
    ccAccount As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> wszAccount As System.Text.StringBuilder   ' LPWSTR out
) As Integer
End Function
' pwszServerName : LPCWSTR
' ccAccount : DWORD
' wszAccount : LPWSTR out
Declare PtrSafe Function GetNetScheduleAccountInformation Lib "mstask" ( _
    ByVal pwszServerName As LongPtr, _
    ByVal ccAccount As Long, _
    ByVal wszAccount As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetNetScheduleAccountInformation = ctypes.windll.mstask.GetNetScheduleAccountInformation
GetNetScheduleAccountInformation.restype = ctypes.c_int
GetNetScheduleAccountInformation.argtypes = [
    wintypes.LPCWSTR,  # pwszServerName : LPCWSTR
    wintypes.DWORD,  # ccAccount : DWORD
    wintypes.LPWSTR,  # wszAccount : LPWSTR out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mstask.dll')
GetNetScheduleAccountInformation = Fiddle::Function.new(
  lib['GetNetScheduleAccountInformation'],
  [
    Fiddle::TYPE_VOIDP,  # pwszServerName : LPCWSTR
    -Fiddle::TYPE_INT,  # ccAccount : DWORD
    Fiddle::TYPE_VOIDP,  # wszAccount : LPWSTR out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mstask")]
extern "system" {
    fn GetNetScheduleAccountInformation(
        pwszServerName: *const u16,  // LPCWSTR
        ccAccount: u32,  // DWORD
        wszAccount: *mut u16  // LPWSTR out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mstask.dll")]
public static extern int GetNetScheduleAccountInformation([MarshalAs(UnmanagedType.LPWStr)] string pwszServerName, uint ccAccount, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wszAccount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mstask_GetNetScheduleAccountInformation' -Namespace Win32 -PassThru
# $api::GetNetScheduleAccountInformation(pwszServerName, ccAccount, wszAccount)
#uselib "mstask.dll"
#func global GetNetScheduleAccountInformation "GetNetScheduleAccountInformation" sptr, sptr, sptr
; GetNetScheduleAccountInformation pwszServerName, ccAccount, varptr(wszAccount)   ; 戻り値は stat
; pwszServerName : LPCWSTR -> "sptr"
; ccAccount : DWORD -> "sptr"
; wszAccount : LPWSTR out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mstask.dll"
#cfunc global GetNetScheduleAccountInformation "GetNetScheduleAccountInformation" wstr, int, var
; res = GetNetScheduleAccountInformation(pwszServerName, ccAccount, wszAccount)
; pwszServerName : LPCWSTR -> "wstr"
; ccAccount : DWORD -> "int"
; wszAccount : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetNetScheduleAccountInformation(LPCWSTR pwszServerName, DWORD ccAccount, LPWSTR wszAccount)
#uselib "mstask.dll"
#cfunc global GetNetScheduleAccountInformation "GetNetScheduleAccountInformation" wstr, int, var
; res = GetNetScheduleAccountInformation(pwszServerName, ccAccount, wszAccount)
; pwszServerName : LPCWSTR -> "wstr"
; ccAccount : DWORD -> "int"
; wszAccount : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mstask = windows.NewLazySystemDLL("mstask.dll")
	procGetNetScheduleAccountInformation = mstask.NewProc("GetNetScheduleAccountInformation")
)

// pwszServerName (LPCWSTR), ccAccount (DWORD), wszAccount (LPWSTR out)
r1, _, err := procGetNetScheduleAccountInformation.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszServerName))),
	uintptr(ccAccount),
	uintptr(wszAccount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetNetScheduleAccountInformation(
  pwszServerName: PWideChar;   // LPCWSTR
  ccAccount: DWORD;   // DWORD
  wszAccount: PWideChar   // LPWSTR out
): Integer; stdcall;
  external 'mstask.dll' name 'GetNetScheduleAccountInformation';
result := DllCall("mstask\GetNetScheduleAccountInformation"
    , "WStr", pwszServerName   ; LPCWSTR
    , "UInt", ccAccount   ; DWORD
    , "Ptr", wszAccount   ; LPWSTR out
    , "Int")   ; return: HRESULT
●GetNetScheduleAccountInformation(pwszServerName, ccAccount, wszAccount) = DLL("mstask.dll", "int GetNetScheduleAccountInformation(char*, dword, char*)")
# 呼び出し: GetNetScheduleAccountInformation(pwszServerName, ccAccount, wszAccount)
# pwszServerName : LPCWSTR -> "char*"
# ccAccount : DWORD -> "dword"
# wszAccount : LPWSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。