FelicaLib.BindDLL.GetDelegate C# (CSharp) Method

GetDelegate() public method

�w�薼�̃A���}�l�[�W�֐��|�C���^��f���Q�[�g�ɕϊ�
public GetDelegate ( string szProcName, Type typDelegate ) : Delegate
szProcName string �A���}�l�[�W�֐���
typDelegate System.Type �ϊ�����f���Q�[�g��Type
return System.Delegate
        public Delegate GetDelegate(string szProcName, Type typDelegate)
        {
            IntPtr pProc = BindDLL.GetProcAddress(_pModule, szProcName);
            if (pProc != IntPtr.Zero)
            {
                Delegate oDG = Marshal.GetDelegateForFunctionPointer(pProc, typDelegate);
                return oDG;
            }
            int nResult = Marshal.GetHRForLastWin32Error();
            throw Marshal.GetExceptionForHR(nResult);
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Felica()
        {
            // x64対応 20100501 - DeForest
            try
            {
                // プラットフォーム別のロードモジュール名決定(x64/x86サポート、Iteniumはサポート外)
                if (System.IntPtr.Size >= 8)    // x64
                {
                    szDLLname = "felicalib64.dll";
                }
                else                // x86
                {
                    szDLLname = "felicalib.dll";
                }
                // DLLロード
                bdDLL = new BindDLL(szDLLname);
                // エントリー取得
                pasori_open    = (Pasori_open)bdDLL.GetDelegate("pasori_open", typeof(Pasori_open));
                pasori_close   = (Pasori_close)bdDLL.GetDelegate("pasori_close", typeof(Pasori_close));
                pasori_init    = (Pasori_init)bdDLL.GetDelegate("pasori_init", typeof(Pasori_init));
                felica_polling = (Felica_polling)bdDLL.GetDelegate("felica_polling", typeof(Felica_polling));
                felica_free    = (Felica_free)bdDLL.GetDelegate("felica_free", typeof(Felica_free));
                felica_getidm  = (Felica_getidm)bdDLL.GetDelegate("felica_getidm", typeof(Felica_getidm));
                felica_getpmm  = (Felica_getpmm)bdDLL.GetDelegate("felica_getpmm", typeof(Felica_getpmm));
                felica_read_without_encryption02 = (Felica_read_without_encryption02)bdDLL.GetDelegate("felica_read_without_encryption02", typeof(Felica_read_without_encryption02));
            }
            catch (Exception)
            {
                throw new Exception(szDLLname + " をロードできません");
            }

            pasorip = pasori_open(null);
            if (pasorip == IntPtr.Zero)
            {
                throw new Exception(szDLLname + " を開けません");
            }
            if (pasori_init(pasorip) != 0)
            {
                throw new Exception("PaSoRi に接続できません");
            }
        }
All Usage Examples Of FelicaLib.BindDLL::GetDelegate