完全没有问题,以下是代码:
Private Declare Function WeiXinPayCodeEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal Lockmchid As String, ByVal Idkey As String, ByVal IdkeyLock As Integer, ByVal AuthCode As String, ByVal OrdNum As String, ByVal TotalFee As String, ByRef outinf As Any) As Integer
Private Declare Function WeiXinPayQRCodeEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal Lockmchid As String, ByVal Idkey As String, ByVal IdkeyLock As Integer, ByVal OrdNum As String, ByVal TotalFee As String, ByRef outinf As Any) As Integer
Private Declare Function WeiXinQueryEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal Lockmchid As String, ByVal Idkey As String, ByVal IdkeyLock As Integer, ByVal OrdNum As String, ByRef outinf As Any) As Integer
Private Declare Function ZhiFuBaoPayCodeEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal AuthCode As String, ByVal OrdNum As String, ByVal TotalFee As String, ByRef outinf As Any) As Integer
Private Declare Function ZhiFuBaoPayQRCodeEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal OrdNum As String, ByVal TotalFee As String, ByRef outinf As Any) As Integer
Private Declare Function ZhiFuBaoQueryEx1 Lib "PayApiFun.dll" (ByVal Lockappid As String, ByVal OrdNum As String, ByRef outinf As Any) As Integer
Private Sub Command16_Click()
'生成微信支付二维码
Dim resul As Integer
Dim Lockappid As String
Dim Lockmchid As String
Dim Idkey As String
Dim IdkeyLock As Integer
Dim AuthCode As String
Dim OrdNum As String
Dim TotalFee As String
Dim outinf(255) As Byte
Text4 = ""
Lockappid = Trim(WXGZH.Text)
'加密后的微信公众账号
Lockmchid = Trim(WXSFH.Text)
'加密后的商户号
Idkey = Trim(WXKEY.Text)
'KEY
If Option2.Value Then IdkeyLock = 1 Else IdkeyLock = 0
'1 KEY已加密,0不加密
OrdNum = Trim(Text2.Text)
TotalFee = Trim(Text3.Text)
'总计支付金额,单位分
If OrdNum = "" Then MsgBox "请输入商户号内的唯一订单编号!", vbCritical + vbOKOnly, "提示": Text2.SetFocus: Exit Sub
Command16.Caption = "正在申请,请稍后..."
Command16.Enabled = False
resul = WeiXinPayQRCodeEx1(Lockappid, Lockmchid, Idkey, IdkeyLock, OrdNum, TotalFee, VarPtr(outinf(0)))
Select Case resul
Case 0
Text6.Text = Trim(MidB(StrConv(outinf, vbUnicode), 1, 255))
Text4.Text = "微信支付单号‘" + OrdNum + "’支付二维码已经生成,有效时间5分钟,可轮询调用‘查询微信订单状态’函数查询支付结果!"
Image1.Picture = LoadPicture(App.Path & "QRcode.BMP")
Case 1
Text4.Text = "微信支付单号‘" + OrdNum + "’正在申请支付二维码..." + Trim(MidB(StrConv(outinf, vbUnicode), 1, 255))
Case -10
Text4.Text = "微信支付单号‘" + OrdNum + "’二维支付地址:" + Trim(MidB(StrConv(outinf, vbUnicode), 1, 255))
Case Else
Text4.Text = "微信支付单号‘" + OrdNum + "’二维支付地址申请失败!" + Trim(MidB(StrConv(outinf, vbUnicode), 1, 255))
End Select
Command16.Caption = "生成微信支付二维码 Ex1"
Command16.Enabled = True
End Sub
Private Sub Command5_Click()
’按单号查询支付结果
Dim Lockappid As String
Dim Lockmchid As String
Dim Idkey As String
Dim IdkeyLock As Integer
Dim AuthCode As String
Dim OrdNum As String
Dim TotalFee As String
Dim outinf(255) As Byte
Text4 = ""
Lockappid = Trim(WXGZH.Text)
'加密后的微信公众账号
Lockmchid = Trim(WXSFH.Text)
'加密后的商户号
Idkey = Trim(WXKEY.Text)
'KEY
If Option2.Value Then IdkeyLock = 1 Else IdkeyLock = 0
'1 KEY已加密,0不加密
OrdNum = Trim(Text2.Text)
If OrdNum = "" Then MsgBox "请输入商户号内的唯一订单编号!", vbCritical + vbOKOnly, "提示": Text2.SetFocus: Exit Sub
Command5.Enabled = False
Command5.Caption = "正在查询中,请稍后..."
WeiXinQueryEx1 Lockappid, Lockmchid, Idkey, IdkeyLock, OrdNum, VarPtr(outinf(0))
Text4.Text = MidB(StrConv(outinf, vbUnicode), 1, 255)
Command5.Enabled = True
Command5.Caption = "查询订单状态 Ex1"
End Sub