キャリブレーションデータの読み込み (ストリーム指定)

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static int fnFIE_xyqn_load(
	FHANDLE hcalib,
	ref fvstream strm
)
Visual Basic
Public Shared Function fnFIE_xyqn_load ( 
	hcalib As FHANDLE,
	ByRef strm As fvstream
) As Integer

Parameters

hcalib
Type: fvalgcli..::..FHANDLE
キャリブレーションシステムのハンドル
strm
Type: fvalgcli..::..fvstream%
データストリーム

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_OBJECT 不正なオブジェクトが渡された
F_ERR_INVALID_PARAM 不正なパラメータが渡された
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Remarks

この関数は、ファイル以外のストリームから読み込む際に使用します。
ストレージ上のファイルから読み込む場合は fnFIE_xyqn_load(FHANDLE, String) をご使用ください。

Examples

下記コードは、ファイルストリームから読む込む処理(※)です。
(※ fnFIE_xyqn_load(FHANDLE, String) の内部実装です。)

C# Copy imageCopy
public static int fnFIE_xyqn_load(FHANDLE hcalib, string filename)
{
    fvstream strm = new fvstream();

    try
    {
        fvstreamDelegate pread = new fvstreamDelegate(fvstream_fread);
        fvstreamDelegate pwrite = new fvstreamDelegate(fvstream_fwrite);

        strm.stream = _wfopen(filename, "rb");
        strm.read = Marshal.GetFunctionPointerForDelegate(pread);
        strm.write = Marshal.GetFunctionPointerForDelegate(pwrite);

        return fnFIE_xyqn_load(hcalib, ref strm);
    }
    finally
    {
        fclose(strm.stream);
    }
}

internal static int fvstream_fread(IntPtr data, int size, IntPtr stream)
{
    IntPtr result = fread(data, new IntPtr(1), new IntPtr(size), stream);
    return result.ToInt32();
}

internal static int fvstream_fwrite(IntPtr data, int size, IntPtr stream)
{
    IntPtr result = fwrite(data, new IntPtr(1), new IntPtr(size), stream);
    return result.ToInt32();
}

[DllImport("msvcrt", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern IntPtr _wfopen(string filename, string mode);

[DllImport("msvcrt", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool fclose(IntPtr stream);

[DllImport("msvcrt", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern IntPtr fread(IntPtr buffer, IntPtr size, IntPtr count, IntPtr stream);

[DllImport("msvcrt", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern IntPtr fwrite(IntPtr buffer, IntPtr size, IntPtr count, IntPtr stream);

See Also