ホーム › NetworkManagement.NetManagement › SetNetScheduleAccountInformation
SetNetScheduleAccountInformation
関数タスクスケジューラの実行アカウントとパスワードを設定する。
シグネチャ
// mstask.dll
#include <windows.h>
HRESULT SetNetScheduleAccountInformation(
LPCWSTR pwszServerName,
LPCWSTR pwszAccount,
LPCWSTR pwszPassword
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pwszServerName | LPCWSTR | in |
| pwszAccount | LPCWSTR | in |
| pwszPassword | LPCWSTR | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// mstask.dll
#include <windows.h>
HRESULT SetNetScheduleAccountInformation(
LPCWSTR pwszServerName,
LPCWSTR pwszAccount,
LPCWSTR pwszPassword
);[DllImport("mstask.dll", ExactSpelling = true)]
static extern int SetNetScheduleAccountInformation(
[MarshalAs(UnmanagedType.LPWStr)] string pwszServerName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwszAccount, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwszPassword // LPCWSTR
);<DllImport("mstask.dll", ExactSpelling:=True)>
Public Shared Function SetNetScheduleAccountInformation(
<MarshalAs(UnmanagedType.LPWStr)> pwszServerName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwszAccount As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwszPassword As String ' LPCWSTR
) As Integer
End Function' pwszServerName : LPCWSTR
' pwszAccount : LPCWSTR
' pwszPassword : LPCWSTR
Declare PtrSafe Function SetNetScheduleAccountInformation Lib "mstask" ( _
ByVal pwszServerName As LongPtr, _
ByVal pwszAccount As LongPtr, _
ByVal pwszPassword As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetNetScheduleAccountInformation = ctypes.windll.mstask.SetNetScheduleAccountInformation
SetNetScheduleAccountInformation.restype = ctypes.c_int
SetNetScheduleAccountInformation.argtypes = [
wintypes.LPCWSTR, # pwszServerName : LPCWSTR
wintypes.LPCWSTR, # pwszAccount : LPCWSTR
wintypes.LPCWSTR, # pwszPassword : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mstask.dll')
SetNetScheduleAccountInformation = Fiddle::Function.new(
lib['SetNetScheduleAccountInformation'],
[
Fiddle::TYPE_VOIDP, # pwszServerName : LPCWSTR
Fiddle::TYPE_VOIDP, # pwszAccount : LPCWSTR
Fiddle::TYPE_VOIDP, # pwszPassword : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "mstask")]
extern "system" {
fn SetNetScheduleAccountInformation(
pwszServerName: *const u16, // LPCWSTR
pwszAccount: *const u16, // LPCWSTR
pwszPassword: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("mstask.dll")]
public static extern int SetNetScheduleAccountInformation([MarshalAs(UnmanagedType.LPWStr)] string pwszServerName, [MarshalAs(UnmanagedType.LPWStr)] string pwszAccount, [MarshalAs(UnmanagedType.LPWStr)] string pwszPassword);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mstask_SetNetScheduleAccountInformation' -Namespace Win32 -PassThru
# $api::SetNetScheduleAccountInformation(pwszServerName, pwszAccount, pwszPassword)#uselib "mstask.dll"
#func global SetNetScheduleAccountInformation "SetNetScheduleAccountInformation" sptr, sptr, sptr
; SetNetScheduleAccountInformation pwszServerName, pwszAccount, pwszPassword ; 戻り値は stat
; pwszServerName : LPCWSTR -> "sptr"
; pwszAccount : LPCWSTR -> "sptr"
; pwszPassword : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "mstask.dll"
#cfunc global SetNetScheduleAccountInformation "SetNetScheduleAccountInformation" wstr, wstr, wstr
; res = SetNetScheduleAccountInformation(pwszServerName, pwszAccount, pwszPassword)
; pwszServerName : LPCWSTR -> "wstr"
; pwszAccount : LPCWSTR -> "wstr"
; pwszPassword : LPCWSTR -> "wstr"; HRESULT SetNetScheduleAccountInformation(LPCWSTR pwszServerName, LPCWSTR pwszAccount, LPCWSTR pwszPassword)
#uselib "mstask.dll"
#cfunc global SetNetScheduleAccountInformation "SetNetScheduleAccountInformation" wstr, wstr, wstr
; res = SetNetScheduleAccountInformation(pwszServerName, pwszAccount, pwszPassword)
; pwszServerName : LPCWSTR -> "wstr"
; pwszAccount : LPCWSTR -> "wstr"
; pwszPassword : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mstask = windows.NewLazySystemDLL("mstask.dll")
procSetNetScheduleAccountInformation = mstask.NewProc("SetNetScheduleAccountInformation")
)
// pwszServerName (LPCWSTR), pwszAccount (LPCWSTR), pwszPassword (LPCWSTR)
r1, _, err := procSetNetScheduleAccountInformation.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszAccount))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszPassword))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SetNetScheduleAccountInformation(
pwszServerName: PWideChar; // LPCWSTR
pwszAccount: PWideChar; // LPCWSTR
pwszPassword: PWideChar // LPCWSTR
): Integer; stdcall;
external 'mstask.dll' name 'SetNetScheduleAccountInformation';result := DllCall("mstask\SetNetScheduleAccountInformation"
, "WStr", pwszServerName ; LPCWSTR
, "WStr", pwszAccount ; LPCWSTR
, "WStr", pwszPassword ; LPCWSTR
, "Int") ; return: HRESULT●SetNetScheduleAccountInformation(pwszServerName, pwszAccount, pwszPassword) = DLL("mstask.dll", "int SetNetScheduleAccountInformation(char*, char*, char*)")
# 呼び出し: SetNetScheduleAccountInformation(pwszServerName, pwszAccount, pwszPassword)
# pwszServerName : LPCWSTR -> "char*"
# pwszAccount : LPCWSTR -> "char*"
# pwszPassword : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。