DLL�x���o�C���f�B���O�N���X
Inheritance: IDisposable
Example #1
0
 public void Dispose()
 {
     if (_pModule != IntPtr.Zero)
     {
         BindDLL.FreeLibrary(_pModule);
     }
 }
Example #2
0
        /// <summary>
        /// DLLのロード・オブジェクト生成
        /// </summary>
        /// <param name="szFilename">バインドするDLL名</param>
        public BindDLL(string szFilename)
        {
            _pModule = BindDLL.LoadLibrary(szFilename);
            if (_pModule != IntPtr.Zero)
            {
                return;
            }
            int nResult = Marshal.GetHRForLastWin32Error();

            throw Marshal.GetExceptionForHR(nResult);
        }
Example #3
0
 /// <summary>
 /// オブジェクト破棄時処理
 /// </summary>
 public void Dispose()
 {
     if (pasorip != IntPtr.Zero)
     {
         pasori_close(pasorip);
         pasorip = IntPtr.Zero;
     }
     if (bdDLL != null)
     {
         bdDLL = null;
     }
 }
Example #4
0
        /// <summary>
        /// 指定名のアンマネージ関数ポインタをデリゲートに変換
        /// </summary>
        /// <param name="szProcName">アンマネージ関数名</param>
        /// <param name="typDelegate">変換するデリゲートのType</param>
        /// <returns>変換したデリゲート</returns>
        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);
        }
Example #5
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 に接続できません");
            }
        }
Example #6
0
 /// <summary>
 /// �I�u�W�F�N�g�j��������
 /// </summary>
 public void Dispose()
 {
     if (pasorip != IntPtr.Zero)
     {
         pasori_close(pasorip);
         pasorip = IntPtr.Zero;
     }
     if (bdDLL != null)
     {
         bdDLL = null;
     }
 }
Example #7
0
        /// <summary>
        /// �R���X�g���N�^
        /// </summary>
        public Felica()
        {
            // x64�Ή� 20100501 - DeForest
            try
            {
                // �v���b�g�t�H�[���ʂ̃��[�h���W���[��������ix64/x86�T�|�[�g�AItenium�̓T�|�[�g�O�j
                if (System.IntPtr.Size >= 8)    // x64
                {
                    szDLLname = "felicalib64.dll";
                }
                else                // x86
                {
                    szDLLname = "felicalib.dll";
                }
                // DLL���[�h
                bdDLL = new BindDLL(szDLLname);
                // �G���g���[�擾
                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 + " ����[�h�ł��܂���");
            }

            pasorip = pasori_open(null);
            if (pasorip == IntPtr.Zero)
            {
                throw new Exception(szDLLname + " ��J���܂���");
            }
            if (pasori_init(pasorip) != 0)
            {
                throw new Exception("PaSoRi �ɐڑ��ł��܂���");
            }
        }