ホーム › Networking.WinInet › RunOnceUrlCache
RunOnceUrlCache
関数URLキャッシュの初回実行処理を行う。
シグネチャ
// WININET.dll
#include <windows.h>
DWORD RunOnceUrlCache(
HWND hwnd,
HINSTANCE hinst,
LPSTR lpszCmd,
INT nCmdShow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | 呼び出し元のウィンドウハンドル。RunDLL32経由で渡される親ウィンドウ。 |
| hinst | HINSTANCE | in | 呼び出し元モジュールのインスタンスハンドル。RunDLL32が渡す。 |
| lpszCmd | LPSTR | in | コマンドラインを示すANSI文字列。処理対象や動作の指定に使われる。 |
| nCmdShow | INT | in | ウィンドウ表示状態を示すShowWindow定数(SW_SHOW等)。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WININET.dll
#include <windows.h>
DWORD RunOnceUrlCache(
HWND hwnd,
HINSTANCE hinst,
LPSTR lpszCmd,
INT nCmdShow
);[DllImport("WININET.dll", ExactSpelling = true)]
static extern uint RunOnceUrlCache(
IntPtr hwnd, // HWND
IntPtr hinst, // HINSTANCE
[MarshalAs(UnmanagedType.LPStr)] string lpszCmd, // LPSTR
int nCmdShow // INT
);<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function RunOnceUrlCache(
hwnd As IntPtr, ' HWND
hinst As IntPtr, ' HINSTANCE
<MarshalAs(UnmanagedType.LPStr)> lpszCmd As String, ' LPSTR
nCmdShow As Integer ' INT
) As UInteger
End Function' hwnd : HWND
' hinst : HINSTANCE
' lpszCmd : LPSTR
' nCmdShow : INT
Declare PtrSafe Function RunOnceUrlCache Lib "wininet" ( _
ByVal hwnd As LongPtr, _
ByVal hinst As LongPtr, _
ByVal lpszCmd As String, _
ByVal nCmdShow As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RunOnceUrlCache = ctypes.windll.wininet.RunOnceUrlCache
RunOnceUrlCache.restype = wintypes.DWORD
RunOnceUrlCache.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.HANDLE, # hinst : HINSTANCE
wintypes.LPCSTR, # lpszCmd : LPSTR
ctypes.c_int, # nCmdShow : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
RunOnceUrlCache = Fiddle::Function.new(
lib['RunOnceUrlCache'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # hinst : HINSTANCE
Fiddle::TYPE_VOIDP, # lpszCmd : LPSTR
Fiddle::TYPE_INT, # nCmdShow : INT
],
-Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn RunOnceUrlCache(
hwnd: *mut core::ffi::c_void, // HWND
hinst: *mut core::ffi::c_void, // HINSTANCE
lpszCmd: *mut u8, // LPSTR
nCmdShow: i32 // INT
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WININET.dll")]
public static extern uint RunOnceUrlCache(IntPtr hwnd, IntPtr hinst, [MarshalAs(UnmanagedType.LPStr)] string lpszCmd, int nCmdShow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_RunOnceUrlCache' -Namespace Win32 -PassThru
# $api::RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)#uselib "WININET.dll"
#func global RunOnceUrlCache "RunOnceUrlCache" sptr, sptr, sptr, sptr
; RunOnceUrlCache hwnd, hinst, lpszCmd, nCmdShow ; 戻り値は stat
; hwnd : HWND -> "sptr"
; hinst : HINSTANCE -> "sptr"
; lpszCmd : LPSTR -> "sptr"
; nCmdShow : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WININET.dll"
#cfunc global RunOnceUrlCache "RunOnceUrlCache" sptr, sptr, str, int
; res = RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
; hwnd : HWND -> "sptr"
; hinst : HINSTANCE -> "sptr"
; lpszCmd : LPSTR -> "str"
; nCmdShow : INT -> "int"; DWORD RunOnceUrlCache(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmd, INT nCmdShow)
#uselib "WININET.dll"
#cfunc global RunOnceUrlCache "RunOnceUrlCache" intptr, intptr, str, int
; res = RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
; hwnd : HWND -> "intptr"
; hinst : HINSTANCE -> "intptr"
; lpszCmd : LPSTR -> "str"
; nCmdShow : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procRunOnceUrlCache = wininet.NewProc("RunOnceUrlCache")
)
// hwnd (HWND), hinst (HINSTANCE), lpszCmd (LPSTR), nCmdShow (INT)
r1, _, err := procRunOnceUrlCache.Call(
uintptr(hwnd),
uintptr(hinst),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszCmd))),
uintptr(nCmdShow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RunOnceUrlCache(
hwnd: THandle; // HWND
hinst: THandle; // HINSTANCE
lpszCmd: PAnsiChar; // LPSTR
nCmdShow: Integer // INT
): DWORD; stdcall;
external 'WININET.dll' name 'RunOnceUrlCache';result := DllCall("WININET\RunOnceUrlCache"
, "Ptr", hwnd ; HWND
, "Ptr", hinst ; HINSTANCE
, "AStr", lpszCmd ; LPSTR
, "Int", nCmdShow ; INT
, "UInt") ; return: DWORD●RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow) = DLL("WININET.dll", "dword RunOnceUrlCache(void*, void*, char*, int)")
# 呼び出し: RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
# hwnd : HWND -> "void*"
# hinst : HINSTANCE -> "void*"
# lpszCmd : LPSTR -> "char*"
# nCmdShow : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wininet" fn RunOnceUrlCache(
hwnd: ?*anyopaque, // HWND
hinst: ?*anyopaque, // HINSTANCE
lpszCmd: [*c]const u8, // LPSTR
nCmdShow: i32 // INT
) callconv(std.os.windows.WINAPI) u32;proc RunOnceUrlCache(
hwnd: pointer, # HWND
hinst: pointer, # HINSTANCE
lpszCmd: cstring, # LPSTR
nCmdShow: int32 # INT
): uint32 {.importc: "RunOnceUrlCache", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
uint RunOnceUrlCache(
void* hwnd, // HWND
void* hinst, // HINSTANCE
const(char)* lpszCmd, // LPSTR
int nCmdShow // INT
);ccall((:RunOnceUrlCache, "WININET.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Int32),
hwnd, hinst, lpszCmd, nCmdShow)
# hwnd : HWND -> Ptr{Cvoid}
# hinst : HINSTANCE -> Ptr{Cvoid}
# lpszCmd : LPSTR -> Cstring
# nCmdShow : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RunOnceUrlCache(
void* hwnd,
void* hinst,
const char* lpszCmd,
int32_t nCmdShow);
]]
local wininet = ffi.load("wininet")
-- wininet.RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
-- hwnd : HWND
-- hinst : HINSTANCE
-- lpszCmd : LPSTR
-- nCmdShow : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const RunOnceUrlCache = lib.func('__stdcall', 'RunOnceUrlCache', 'uint32_t', ['void *', 'void *', 'str', 'int32_t']);
// RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
// hwnd : HWND -> 'void *'
// hinst : HINSTANCE -> 'void *'
// lpszCmd : LPSTR -> 'str'
// nCmdShow : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
RunOnceUrlCache: { parameters: ["pointer", "pointer", "buffer", "i32"], result: "u32" },
});
// lib.symbols.RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow)
// hwnd : HWND -> "pointer"
// hinst : HINSTANCE -> "pointer"
// lpszCmd : LPSTR -> "buffer"
// nCmdShow : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RunOnceUrlCache(
void* hwnd,
void* hinst,
const char* lpszCmd,
int32_t nCmdShow);
C, "WININET.dll");
// $ffi->RunOnceUrlCache(hwnd, hinst, lpszCmd, nCmdShow);
// hwnd : HWND
// hinst : HINSTANCE
// lpszCmd : LPSTR
// nCmdShow : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class);
int RunOnceUrlCache(
Pointer hwnd, // HWND
Pointer hinst, // HINSTANCE
String lpszCmd, // LPSTR
int nCmdShow // INT
);
}@[Link("wininet")]
lib LibWININET
fun RunOnceUrlCache = RunOnceUrlCache(
hwnd : Void*, # HWND
hinst : Void*, # HINSTANCE
lpszCmd : UInt8*, # LPSTR
nCmdShow : Int32 # INT
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RunOnceUrlCacheNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Int32);
typedef RunOnceUrlCacheDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, int);
final RunOnceUrlCache = DynamicLibrary.open('WININET.dll')
.lookupFunction<RunOnceUrlCacheNative, RunOnceUrlCacheDart>('RunOnceUrlCache');
// hwnd : HWND -> Pointer<Void>
// hinst : HINSTANCE -> Pointer<Void>
// lpszCmd : LPSTR -> Pointer<Utf8>
// nCmdShow : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RunOnceUrlCache(
hwnd: THandle; // HWND
hinst: THandle; // HINSTANCE
lpszCmd: PAnsiChar; // LPSTR
nCmdShow: Integer // INT
): DWORD; stdcall;
external 'WININET.dll' name 'RunOnceUrlCache';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RunOnceUrlCache"
c_RunOnceUrlCache :: Ptr () -> Ptr () -> CString -> Int32 -> IO Word32
-- hwnd : HWND -> Ptr ()
-- hinst : HINSTANCE -> Ptr ()
-- lpszCmd : LPSTR -> CString
-- nCmdShow : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let runonceurlcache =
foreign "RunOnceUrlCache"
((ptr void) @-> (ptr void) @-> string @-> int32_t @-> returning uint32_t)
(* hwnd : HWND -> (ptr void) *)
(* hinst : HINSTANCE -> (ptr void) *)
(* lpszCmd : LPSTR -> string *)
(* nCmdShow : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("RunOnceUrlCache" run-once-url-cache :convention :stdcall) :uint32
(hwnd :pointer) ; HWND
(hinst :pointer) ; HINSTANCE
(lpsz-cmd :string) ; LPSTR
(n-cmd-show :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RunOnceUrlCache = Win32::API::More->new('WININET',
'DWORD RunOnceUrlCache(HANDLE hwnd, HANDLE hinst, LPCSTR lpszCmd, int nCmdShow)');
# my $ret = $RunOnceUrlCache->Call($hwnd, $hinst, $lpszCmd, $nCmdShow);
# hwnd : HWND -> HANDLE
# hinst : HINSTANCE -> HANDLE
# lpszCmd : LPSTR -> LPCSTR
# nCmdShow : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。