通过C#开发Com控件,注册到系统,然后由pb通过OLEObject进行调用
原文:https://www.cnblogs.com/eric_ibm/archive/2012/07/06/dll.html
代码(VS2010)+ 动态库:https://pan.baidu.com/s/17jFggInvIaYD_kEDqHhRpg
PB代码:
//==================================================================== // 事件: u_sysfunc.uf_encrypt_aes128() //-------------------------------------------------------------------- // 描述: aes128 加密 //-------------------------------------------------------------------- // 参数: // value string as_key 秘钥 // value string as_data 被加密数据 // reference string as_data_encrypted 密文 //-------------------------------------------------------------------- // 返回: string //-------------------------------------------------------------------- // 修改历史: // //==================================================================== Int li_ret String ls_msg OLEObject encryption //调用第三方库进行加密 Try encryption = Create OLEObject li_ret = encryption.ConnectToNewObject("com.cz.encry.Encryption") If li_ret <> 0 Then as_data_encrypted = '调用加密COM组件错误' If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return -1 End If as_data_encrypted = encryption.Encrypt(as_data, as_key) Catch (RuntimeError e) ls_msg = e.getmessage() as_data_encrypted = '加密出错:' + ls_msg If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return -1 End Try If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return 1
//==================================================================== // 事件: u_sysfunc.uf_decrypt_aes128() //-------------------------------------------------------------------- // 描述: aes128 解密 //-------------------------------------------------------------------- // 参数: // value string as_key 秘钥 // value string as_data 被解密数据 // reference string as_data_decrypted //-------------------------------------------------------------------- // 修改历史: // //==================================================================== Int li_ret String ls_msg OLEObject encryption //调用第三方库进行解密 Try encryption = Create OLEObject li_ret = encryption.ConnectToNewObject("com.cz.encry.Encryption") If li_ret <> 0 Then as_data_decrypted = '调用解密COM组件错误' If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return -1 End If as_data_decrypted = encryption.Decrypt(as_data, as_key) Catch (RuntimeError e) ls_msg = e.getmessage() as_data_decrypted = '解密出错:' + ls_msg If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return -1 End Try If Isvalid(encryption) Then encryption.DisconnectObject() Destroy encryption End If Return 1