很多人使用VB6来编写实用程序,但是VB6有些功能实现,太费劲了。
但是,VB提供了标准的COM接口---只要在Windows下运行的程序经过转换VB都可以调用!
本人(xiaobin)通过以前做给客户的DLL文件,来做一个抛砖引玉!希望给有此兴趣和需要的人提供一个帮助!
DLL提供的功能主要为文件校验之用!(根据C程序,使用Delphi实现)
有兴趣改写C程序的网上有很多!
本篇就讲一下程序1!
程序1只有一个按钮事件,cmdCall_Click()
'调用过程 Call saveFCN(saveFile1,CheckFilePath1)
此接口有两个参数:
saveFile1:要保存的文件名(包含路径)
CheckFilePath1:要校验的文件名(包含路径)
他们都是字符串类型,即String。
外调函数声明:
'vb define Option Explicit Private Declare Sub saveFCN Lib "FCN.dll" (ByVal saveFile1 As String,ByVal CheckFilePath As String)
下面是完整的代码(frmDemo.frm):
VERSION 5.00 Begin VB.Form frmDemo Caption = "调用FCN文件校验DEMO" ClientHeight = 2955 ClientLeft = 60 ClientTop = 345 ClientWidth = 4455 BeginProperty Font Name = "宋体" Size = 9.75 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 2955 ScaleWidth = 4455 StartUpPosition = 2 'CenterScreen Begin VB.TextBox fcnPathTxt Height = 375 Left = 720 TabIndex = 2 Text = "c:\s\datasb.fcn" Top = 1440 Width = 3495 End Begin VB.TextBox Text1 Height = 375 Left = 720 TabIndex = 1 Text = "c:\s\datasb.rar" Top = 600 Width = 3495 End Begin VB.CommandButton cmdCall Caption = "调用文件校验过程" Height = 375 Left = 2280 TabIndex = 0 Top = 2160 Width = 1935 End End Attribute VB_Name = "frmDemo" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Declare Sub saveFCN Lib "FCN.dll" (ByVal saveFile1 As String,ByVal CheckFilePath As String) Private Sub cmdCall_Click() '定义要保存的文件和检查的文件(具体路径和文件名称) Dim saveFile1,CheckFilePath1 As String 'saveFile1 = "c:\s\datasb.fcn" CheckFilePath1 = Text1.Text saveFile1 = fcnPathTxt.Text '调用过程 Call saveFCN(saveFile1,CheckFilePath1) frmDemo.Caption = "生成FCN文件-完成" End Sub
本篇End。
========================================如有需转载的,请标明出处!谢谢======================
原文链接:https://www.f2er.com/vb/260015.html