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

ScUNCFromLocalPath

関数
ローカルパスをUNCパスに変換する。
DLLMAPI32.dll呼出規約winapi

シグネチャ

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

INT ScUNCFromLocalPath(
    LPSTR lpszLocal,
    LPSTR lpszUNC,
    DWORD cchUNC
);

パラメーター

名前方向
lpszLocalLPSTRin
lpszUNCLPSTRin
cchUNCDWORDin

戻り値の型: INT

各言語での呼び出し定義

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

INT ScUNCFromLocalPath(
    LPSTR lpszLocal,
    LPSTR lpszUNC,
    DWORD cchUNC
);
[DllImport("MAPI32.dll", ExactSpelling = true)]
static extern int ScUNCFromLocalPath(
    [MarshalAs(UnmanagedType.LPStr)] string lpszLocal,   // LPSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszUNC,   // LPSTR
    uint cchUNC   // DWORD
);
<DllImport("MAPI32.dll", ExactSpelling:=True)>
Public Shared Function ScUNCFromLocalPath(
    <MarshalAs(UnmanagedType.LPStr)> lpszLocal As String,   ' LPSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszUNC As String,   ' LPSTR
    cchUNC As UInteger   ' DWORD
) As Integer
End Function
' lpszLocal : LPSTR
' lpszUNC : LPSTR
' cchUNC : DWORD
Declare PtrSafe Function ScUNCFromLocalPath Lib "mapi32" ( _
    ByVal lpszLocal As String, _
    ByVal lpszUNC As String, _
    ByVal cchUNC As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScUNCFromLocalPath = ctypes.windll.mapi32.ScUNCFromLocalPath
ScUNCFromLocalPath.restype = ctypes.c_int
ScUNCFromLocalPath.argtypes = [
    wintypes.LPCSTR,  # lpszLocal : LPSTR
    wintypes.LPCSTR,  # lpszUNC : LPSTR
    wintypes.DWORD,  # cchUNC : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MAPI32.dll')
ScUNCFromLocalPath = Fiddle::Function.new(
  lib['ScUNCFromLocalPath'],
  [
    Fiddle::TYPE_VOIDP,  # lpszLocal : LPSTR
    Fiddle::TYPE_VOIDP,  # lpszUNC : LPSTR
    -Fiddle::TYPE_INT,  # cchUNC : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "mapi32")]
extern "system" {
    fn ScUNCFromLocalPath(
        lpszLocal: *mut u8,  // LPSTR
        lpszUNC: *mut u8,  // LPSTR
        cchUNC: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MAPI32.dll")]
public static extern int ScUNCFromLocalPath([MarshalAs(UnmanagedType.LPStr)] string lpszLocal, [MarshalAs(UnmanagedType.LPStr)] string lpszUNC, uint cchUNC);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MAPI32_ScUNCFromLocalPath' -Namespace Win32 -PassThru
# $api::ScUNCFromLocalPath(lpszLocal, lpszUNC, cchUNC)
#uselib "MAPI32.dll"
#func global ScUNCFromLocalPath "ScUNCFromLocalPath" sptr, sptr, sptr
; ScUNCFromLocalPath lpszLocal, lpszUNC, cchUNC   ; 戻り値は stat
; lpszLocal : LPSTR -> "sptr"
; lpszUNC : LPSTR -> "sptr"
; cchUNC : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MAPI32.dll"
#cfunc global ScUNCFromLocalPath "ScUNCFromLocalPath" str, str, int
; res = ScUNCFromLocalPath(lpszLocal, lpszUNC, cchUNC)
; lpszLocal : LPSTR -> "str"
; lpszUNC : LPSTR -> "str"
; cchUNC : DWORD -> "int"
; INT ScUNCFromLocalPath(LPSTR lpszLocal, LPSTR lpszUNC, DWORD cchUNC)
#uselib "MAPI32.dll"
#cfunc global ScUNCFromLocalPath "ScUNCFromLocalPath" str, str, int
; res = ScUNCFromLocalPath(lpszLocal, lpszUNC, cchUNC)
; lpszLocal : LPSTR -> "str"
; lpszUNC : LPSTR -> "str"
; cchUNC : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mapi32 = windows.NewLazySystemDLL("MAPI32.dll")
	procScUNCFromLocalPath = mapi32.NewProc("ScUNCFromLocalPath")
)

// lpszLocal (LPSTR), lpszUNC (LPSTR), cchUNC (DWORD)
r1, _, err := procScUNCFromLocalPath.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszLocal))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszUNC))),
	uintptr(cchUNC),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ScUNCFromLocalPath(
  lpszLocal: PAnsiChar;   // LPSTR
  lpszUNC: PAnsiChar;   // LPSTR
  cchUNC: DWORD   // DWORD
): Integer; stdcall;
  external 'MAPI32.dll' name 'ScUNCFromLocalPath';
result := DllCall("MAPI32\ScUNCFromLocalPath"
    , "AStr", lpszLocal   ; LPSTR
    , "AStr", lpszUNC   ; LPSTR
    , "UInt", cchUNC   ; DWORD
    , "Int")   ; return: INT
●ScUNCFromLocalPath(lpszLocal, lpszUNC, cchUNC) = DLL("MAPI32.dll", "int ScUNCFromLocalPath(char*, char*, dword)")
# 呼び出し: ScUNCFromLocalPath(lpszLocal, lpszUNC, cchUNC)
# lpszLocal : LPSTR -> "char*"
# lpszUNC : LPSTR -> "char*"
# cchUNC : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。