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

SQLFreeStmt

関数
ステートメントハンドルのリソースを解放または再設定する。
DLLODBC32.dll呼出規約winapi

シグネチャ

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

SHORT SQLFreeStmt(
    void* StatementHandle,
    WORD Option
);

パラメーター

名前方向説明
StatementHandlevoid*inout操作対象のステートメントハンドル。
OptionWORDin実行する処理。SQL_CLOSE/SQL_UNBIND/SQL_RESET_PARAMS/SQL_DROP等を指定する。

戻り値の型: SHORT

各言語での呼び出し定義

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

SHORT SQLFreeStmt(
    void* StatementHandle,
    WORD Option
);
[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLFreeStmt(
    IntPtr StatementHandle,   // void* in/out
    ushort Option   // WORD
);
<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLFreeStmt(
    StatementHandle As IntPtr,   ' void* in/out
    [Option] As UShort   ' WORD
) As Short
End Function
' StatementHandle : void* in/out
' Option : WORD
Declare PtrSafe Function SQLFreeStmt Lib "odbc32" ( _
    ByVal StatementHandle As LongPtr, _
    ByVal Option As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLFreeStmt = ctypes.windll.odbc32.SQLFreeStmt
SQLFreeStmt.restype = ctypes.c_short
SQLFreeStmt.argtypes = [
    ctypes.POINTER(None),  # StatementHandle : void* in/out
    ctypes.c_ushort,  # Option : WORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLFreeStmt = Fiddle::Function.new(
  lib['SQLFreeStmt'],
  [
    Fiddle::TYPE_VOIDP,  # StatementHandle : void* in/out
    -Fiddle::TYPE_SHORT,  # Option : WORD
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLFreeStmt(
        StatementHandle: *mut (),  // void* in/out
        Option: u16  // WORD
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLFreeStmt(IntPtr StatementHandle, ushort Option);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLFreeStmt' -Namespace Win32 -PassThru
# $api::SQLFreeStmt(StatementHandle, Option)
#uselib "ODBC32.dll"
#func global SQLFreeStmt "SQLFreeStmt" sptr, sptr
; SQLFreeStmt StatementHandle, Option   ; 戻り値は stat
; StatementHandle : void* in/out -> "sptr"
; Option : WORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ODBC32.dll"
#cfunc global SQLFreeStmt "SQLFreeStmt" sptr, int
; res = SQLFreeStmt(StatementHandle, Option)
; StatementHandle : void* in/out -> "sptr"
; Option : WORD -> "int"
; SHORT SQLFreeStmt(void* StatementHandle, WORD Option)
#uselib "ODBC32.dll"
#cfunc global SQLFreeStmt "SQLFreeStmt" intptr, int
; res = SQLFreeStmt(StatementHandle, Option)
; StatementHandle : void* in/out -> "intptr"
; Option : WORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLFreeStmt = odbc32.NewProc("SQLFreeStmt")
)

// StatementHandle (void* in/out), Option (WORD)
r1, _, err := procSQLFreeStmt.Call(
	uintptr(StatementHandle),
	uintptr(Option),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLFreeStmt(
  StatementHandle: Pointer;   // void* in/out
  Option: Word   // WORD
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLFreeStmt';
result := DllCall("ODBC32\SQLFreeStmt"
    , "Ptr", StatementHandle   ; void* in/out
    , "UShort", Option   ; WORD
    , "Short")   ; return: SHORT
●SQLFreeStmt(StatementHandle, Option) = DLL("ODBC32.dll", "int SQLFreeStmt(void*, int)")
# 呼び出し: SQLFreeStmt(StatementHandle, Option)
# StatementHandle : void* in/out -> "void*"
# Option : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "odbc32" fn SQLFreeStmt(
    StatementHandle: ?*anyopaque, // void* in/out
    Option: u16 // WORD
) callconv(std.os.windows.WINAPI) i16;
proc SQLFreeStmt(
    StatementHandle: pointer,  # void* in/out
    Option: uint16  # WORD
): int16 {.importc: "SQLFreeStmt", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLFreeStmt(
    void* StatementHandle,   // void* in/out
    ushort Option   // WORD
);
ccall((:SQLFreeStmt, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, UInt16),
      StatementHandle, Option)
# StatementHandle : void* in/out -> Ptr{Cvoid}
# Option : WORD -> UInt16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLFreeStmt(
    void* StatementHandle,
    uint16_t Option);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLFreeStmt(StatementHandle, Option)
-- StatementHandle : void* in/out
-- Option : WORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLFreeStmt = lib.func('__stdcall', 'SQLFreeStmt', 'int16_t', ['void *', 'uint16_t']);
// SQLFreeStmt(StatementHandle, Option)
// StatementHandle : void* in/out -> 'void *'
// Option : WORD -> 'uint16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLFreeStmt: { parameters: ["pointer", "u16"], result: "i16" },
});
// lib.symbols.SQLFreeStmt(StatementHandle, Option)
// StatementHandle : void* in/out -> "pointer"
// Option : WORD -> "u16"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLFreeStmt(
    void* StatementHandle,
    uint16_t Option);
C, "ODBC32.dll");
// $ffi->SQLFreeStmt(StatementHandle, Option);
// StatementHandle : void* in/out
// Option : WORD
// 構造体/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 Odbc32 extends StdCallLibrary {
    Odbc32 INSTANCE = Native.load("odbc32", Odbc32.class);
    short SQLFreeStmt(
        Pointer StatementHandle,   // void* in/out
        short Option   // WORD
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLFreeStmt = SQLFreeStmt(
    StatementHandle : Void*,   # void* in/out
    Option : UInt16   # WORD
  ) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SQLFreeStmtNative = Int16 Function(Pointer<Void>, Uint16);
typedef SQLFreeStmtDart = int Function(Pointer<Void>, int);
final SQLFreeStmt = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLFreeStmtNative, SQLFreeStmtDart>('SQLFreeStmt');
// StatementHandle : void* in/out -> Pointer<Void>
// Option : WORD -> Uint16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLFreeStmt(
  StatementHandle: Pointer;   // void* in/out
  Option: Word   // WORD
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLFreeStmt';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLFreeStmt"
  c_SQLFreeStmt :: Ptr () -> Word16 -> IO Int16
-- StatementHandle : void* in/out -> Ptr ()
-- Option : WORD -> Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlfreestmt =
  foreign "SQLFreeStmt"
    ((ptr void) @-> uint16_t @-> returning int16_t)
(* StatementHandle : void* in/out -> (ptr void) *)
(* Option : WORD -> uint16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLFreeStmt" sqlfree-stmt :convention :stdcall) :int16
  (statement-handle :pointer)   ; void* in/out
  (option :uint16))   ; WORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLFreeStmt = Win32::API::More->new('ODBC32',
    'short SQLFreeStmt(LPVOID StatementHandle, WORD Option)');
# my $ret = $SQLFreeStmt->Call($StatementHandle, $Option);
# StatementHandle : void* in/out -> LPVOID
# Option : WORD -> WORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。