Exemple #1
0
        void LoadDllAndDelegates()
        {
            dllModulePtr = NativeMethodsHelper.LoadLibrary(dllFileName);

            pasori_open    = NativeMethodsHelper.GetDelegate <Pasori_open>(dllModulePtr, "pasori_open");
            pasori_close   = NativeMethodsHelper.GetDelegate <Pasori_close>(dllModulePtr, "pasori_close");
            pasori_init    = NativeMethodsHelper.GetDelegate <Pasori_init>(dllModulePtr, "pasori_init");
            felica_polling = NativeMethodsHelper.GetDelegate <Felica_polling>(dllModulePtr, "felica_polling");
            felica_free    = NativeMethodsHelper.GetDelegate <Felica_free>(dllModulePtr, "felica_free");
            felica_getidm  = NativeMethodsHelper.GetDelegate <Felica_getidm>(dllModulePtr, "felica_getidm");
            felica_getpmm  = NativeMethodsHelper.GetDelegate <Felica_getpmm>(dllModulePtr, "felica_getpmm");
            felica_read_without_encryption02 = NativeMethodsHelper.GetDelegate <Felica_read_without_encryption02>(dllModulePtr, "felica_read_without_encryption02");
        }
Exemple #2
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 に接続できません");
            }
        }
Exemple #3
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 �ɐڑ��ł��܂���");
            }
        }