ホーム › Networking.WinSock › WSCGetApplicationCategory
WSCGetApplicationCategory
関数アプリケーションのLSPカテゴリ許可を取得する。
シグネチャ
// WS2_32.dll
#include <windows.h>
INT WSCGetApplicationCategory(
LPCWSTR Path,
DWORD PathLength,
LPCWSTR Extra, // optional
DWORD ExtraLength,
DWORD* pPermittedLspCategories,
INT* lpErrno
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Path | LPCWSTR | in |
| PathLength | DWORD | in |
| Extra | LPCWSTR | inoptional |
| ExtraLength | DWORD | in |
| pPermittedLspCategories | DWORD* | out |
| lpErrno | INT* | out |
戻り値の型: INT
各言語での呼び出し定義
// WS2_32.dll
#include <windows.h>
INT WSCGetApplicationCategory(
LPCWSTR Path,
DWORD PathLength,
LPCWSTR Extra, // optional
DWORD ExtraLength,
DWORD* pPermittedLspCategories,
INT* lpErrno
);[DllImport("WS2_32.dll", ExactSpelling = true)]
static extern int WSCGetApplicationCategory(
[MarshalAs(UnmanagedType.LPWStr)] string Path, // LPCWSTR
uint PathLength, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string Extra, // LPCWSTR optional
uint ExtraLength, // DWORD
out uint pPermittedLspCategories, // DWORD* out
out int lpErrno // INT* out
);<DllImport("WS2_32.dll", ExactSpelling:=True)>
Public Shared Function WSCGetApplicationCategory(
<MarshalAs(UnmanagedType.LPWStr)> Path As String, ' LPCWSTR
PathLength As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> Extra As String, ' LPCWSTR optional
ExtraLength As UInteger, ' DWORD
<Out> ByRef pPermittedLspCategories As UInteger, ' DWORD* out
<Out> ByRef lpErrno As Integer ' INT* out
) As Integer
End Function' Path : LPCWSTR
' PathLength : DWORD
' Extra : LPCWSTR optional
' ExtraLength : DWORD
' pPermittedLspCategories : DWORD* out
' lpErrno : INT* out
Declare PtrSafe Function WSCGetApplicationCategory Lib "ws2_32" ( _
ByVal Path As LongPtr, _
ByVal PathLength As Long, _
ByVal Extra As LongPtr, _
ByVal ExtraLength As Long, _
ByRef pPermittedLspCategories As Long, _
ByRef lpErrno As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSCGetApplicationCategory = ctypes.windll.ws2_32.WSCGetApplicationCategory
WSCGetApplicationCategory.restype = ctypes.c_int
WSCGetApplicationCategory.argtypes = [
wintypes.LPCWSTR, # Path : LPCWSTR
wintypes.DWORD, # PathLength : DWORD
wintypes.LPCWSTR, # Extra : LPCWSTR optional
wintypes.DWORD, # ExtraLength : DWORD
ctypes.POINTER(wintypes.DWORD), # pPermittedLspCategories : DWORD* out
ctypes.POINTER(ctypes.c_int), # lpErrno : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WS2_32.dll')
WSCGetApplicationCategory = Fiddle::Function.new(
lib['WSCGetApplicationCategory'],
[
Fiddle::TYPE_VOIDP, # Path : LPCWSTR
-Fiddle::TYPE_INT, # PathLength : DWORD
Fiddle::TYPE_VOIDP, # Extra : LPCWSTR optional
-Fiddle::TYPE_INT, # ExtraLength : DWORD
Fiddle::TYPE_VOIDP, # pPermittedLspCategories : DWORD* out
Fiddle::TYPE_VOIDP, # lpErrno : INT* out
],
Fiddle::TYPE_INT)#[link(name = "ws2_32")]
extern "system" {
fn WSCGetApplicationCategory(
Path: *const u16, // LPCWSTR
PathLength: u32, // DWORD
Extra: *const u16, // LPCWSTR optional
ExtraLength: u32, // DWORD
pPermittedLspCategories: *mut u32, // DWORD* out
lpErrno: *mut i32 // INT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WS2_32.dll")]
public static extern int WSCGetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, out uint pPermittedLspCategories, out int lpErrno);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WS2_32_WSCGetApplicationCategory' -Namespace Win32 -PassThru
# $api::WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, pPermittedLspCategories, lpErrno)#uselib "WS2_32.dll"
#func global WSCGetApplicationCategory "WSCGetApplicationCategory" sptr, sptr, sptr, sptr, sptr, sptr
; WSCGetApplicationCategory Path, PathLength, Extra, ExtraLength, varptr(pPermittedLspCategories), varptr(lpErrno) ; 戻り値は stat
; Path : LPCWSTR -> "sptr"
; PathLength : DWORD -> "sptr"
; Extra : LPCWSTR optional -> "sptr"
; ExtraLength : DWORD -> "sptr"
; pPermittedLspCategories : DWORD* out -> "sptr"
; lpErrno : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WS2_32.dll" #cfunc global WSCGetApplicationCategory "WSCGetApplicationCategory" wstr, int, wstr, int, var, var ; res = WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, pPermittedLspCategories, lpErrno) ; Path : LPCWSTR -> "wstr" ; PathLength : DWORD -> "int" ; Extra : LPCWSTR optional -> "wstr" ; ExtraLength : DWORD -> "int" ; pPermittedLspCategories : DWORD* out -> "var" ; lpErrno : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WS2_32.dll" #cfunc global WSCGetApplicationCategory "WSCGetApplicationCategory" wstr, int, wstr, int, sptr, sptr ; res = WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, varptr(pPermittedLspCategories), varptr(lpErrno)) ; Path : LPCWSTR -> "wstr" ; PathLength : DWORD -> "int" ; Extra : LPCWSTR optional -> "wstr" ; ExtraLength : DWORD -> "int" ; pPermittedLspCategories : DWORD* out -> "sptr" ; lpErrno : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT WSCGetApplicationCategory(LPCWSTR Path, DWORD PathLength, LPCWSTR Extra, DWORD ExtraLength, DWORD* pPermittedLspCategories, INT* lpErrno) #uselib "WS2_32.dll" #cfunc global WSCGetApplicationCategory "WSCGetApplicationCategory" wstr, int, wstr, int, var, var ; res = WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, pPermittedLspCategories, lpErrno) ; Path : LPCWSTR -> "wstr" ; PathLength : DWORD -> "int" ; Extra : LPCWSTR optional -> "wstr" ; ExtraLength : DWORD -> "int" ; pPermittedLspCategories : DWORD* out -> "var" ; lpErrno : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT WSCGetApplicationCategory(LPCWSTR Path, DWORD PathLength, LPCWSTR Extra, DWORD ExtraLength, DWORD* pPermittedLspCategories, INT* lpErrno) #uselib "WS2_32.dll" #cfunc global WSCGetApplicationCategory "WSCGetApplicationCategory" wstr, int, wstr, int, intptr, intptr ; res = WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, varptr(pPermittedLspCategories), varptr(lpErrno)) ; Path : LPCWSTR -> "wstr" ; PathLength : DWORD -> "int" ; Extra : LPCWSTR optional -> "wstr" ; ExtraLength : DWORD -> "int" ; pPermittedLspCategories : DWORD* out -> "intptr" ; lpErrno : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ws2_32 = windows.NewLazySystemDLL("WS2_32.dll")
procWSCGetApplicationCategory = ws2_32.NewProc("WSCGetApplicationCategory")
)
// Path (LPCWSTR), PathLength (DWORD), Extra (LPCWSTR optional), ExtraLength (DWORD), pPermittedLspCategories (DWORD* out), lpErrno (INT* out)
r1, _, err := procWSCGetApplicationCategory.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Path))),
uintptr(PathLength),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Extra))),
uintptr(ExtraLength),
uintptr(pPermittedLspCategories),
uintptr(lpErrno),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction WSCGetApplicationCategory(
Path: PWideChar; // LPCWSTR
PathLength: DWORD; // DWORD
Extra: PWideChar; // LPCWSTR optional
ExtraLength: DWORD; // DWORD
pPermittedLspCategories: Pointer; // DWORD* out
lpErrno: Pointer // INT* out
): Integer; stdcall;
external 'WS2_32.dll' name 'WSCGetApplicationCategory';result := DllCall("WS2_32\WSCGetApplicationCategory"
, "WStr", Path ; LPCWSTR
, "UInt", PathLength ; DWORD
, "WStr", Extra ; LPCWSTR optional
, "UInt", ExtraLength ; DWORD
, "Ptr", pPermittedLspCategories ; DWORD* out
, "Ptr", lpErrno ; INT* out
, "Int") ; return: INT●WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, pPermittedLspCategories, lpErrno) = DLL("WS2_32.dll", "int WSCGetApplicationCategory(char*, dword, char*, dword, void*, void*)")
# 呼び出し: WSCGetApplicationCategory(Path, PathLength, Extra, ExtraLength, pPermittedLspCategories, lpErrno)
# Path : LPCWSTR -> "char*"
# PathLength : DWORD -> "dword"
# Extra : LPCWSTR optional -> "char*"
# ExtraLength : DWORD -> "dword"
# pPermittedLspCategories : DWORD* out -> "void*"
# lpErrno : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。