本篇讲程序2!
本程序主要有两个功能:计算CRC32数值和读取FCN文件的内容。
通过这个两个数值的对比可以发现是否文件被修改过!
1.按钮事件cmdCal_Click()
Label_cal.Caption = calCRC32(filePath1)此接口有1个参数:
'定义要计算的文件(具体路径和文件名称) Dim filePath1 As String
外调函数声明:
'vb defineOption ExplicitPrivate Declare Function calCRC32 lib "FCN.dll" (ByVal filePath1 As String) As Long
2.按钮事件cmdReadfcN_Click()
Label_read.Caption = readfcN(loadfile1)此接口有1个参数:
'定义要读取的文件(具体路径和文件名称) Dim loadfile1 As String
Private Declare Function readfcN lib "FCN.dll" (ByVal loadfile1 As String) As Long
下面是完整的代码(frmDemCrc32.frm):
VERSION 5.00Begin VB.Form frmDemCrc32 Caption = "CRC32演示" ClIEntHeight = 2790 ClIEntleft = 60 ClIEnttop = 345 ClIEntWIDth = 8895 BeginProperty Font name = "宋体" Size = 9.75 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty linktopic = "Form1" ScaleHeight = 2790 ScaleWIDth = 8895 StartUpposition = 2 'CenterScreen Begin VB.TextBox fcnPathTxt Height = 495 left = 600 TabIndex = 7 Text = "c:\s\datasb.fcn" top = 1320 WIDth = 3735 End Begin VB.TextBox filePathTxt Height = 495 left = 600 TabIndex = 6 Text = "c:\s\datasb.txt" top = 360 WIDth = 3735 End Begin VB.Commandbutton cmdReadfcN Caption = "读 FCN 文件" BeginProperty Font name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 left = 7440 TabIndex = 1 top = 1320 WIDth = 1215 End Begin VB.Commandbutton cmdCal Caption = "计算CRC32值" BeginProperty Font name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 left = 7440 TabIndex = 0 top = 360 WIDth = 1215 End Begin VB.Label Label2 Caption = "读取值:" BeginProperty Font name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 left = 4560 TabIndex = 5 top = 1440 WIDth = 735 End Begin VB.Label Label1 Caption = "计算值:" BeginProperty Font name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 left = 4560 TabIndex = 4 top = 480 WIDth = 735 End Begin VB.Label Label_read Forecolor = &H80000001& Height = 495 left = 5640 TabIndex = 3 top = 1440 WIDth = 1605 End Begin VB.Label Label_cal Forecolor = &H80000001& Height = 495 left = 5640 TabIndex = 2 top = 480 WIDth = 1605 EndEndAttribute VB_name = "frmDemCrc32"Attribute VB_GlobalnameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredID = TrueAttribute VB_Exposed = FalseOption ExplicitPrivate Declare Function calCRC32 lib "FCN.dll" (ByVal filePath1 As String) As LongPrivate Declare Function readfcN lib "FCN.dll" (ByVal loadfile1 As String) As LongPrivate Sub cmdCal_Click() '定义要计算的文件(具体路径和文件名称) Dim filePath1 As String filePath1 = filePathTxt.Text '调用函数 Label_cal.Caption = calCRC32(filePath1) End SubPrivate Sub cmdReadfcN_Click() '定义要读取的文件(具体路径和文件名称) Dim loadfile1 As String loadfile1 = fcnPathTxt.Text '调用函数 Label_read.Caption = readfcN(loadfile1)End Sub
附:
说明文件
文件接口
—CRC32动态库(FCN.DLL)
一、函数列表
函数名称 | 参数名称 | 数据类型 | 返回值 | 备注 |
calCRC32 | filePath1 | String | Long | 计算文件的CRC32值 |
readfcN | loadfile1 | String | Long | 读取FCN文件的CRC32值 |
二、VB声明
1.计算文件的CRC32值
‘VB声明
PrivateDeclare Function calCRC32 lib "FCN.dll" (ByVal filePath1 As String)As Long
2.读取FCN文件的CRC32值
‘VB声明
Private Declare Function readfcN lib"FCN.dll" (ByVal loadfile1 As String) As Long
使用说明:(xiaobin)
请把MSVBVM60.DLL和FCN.dll与程序文件在一个目录里!
下载地址:http://download.csdn.net/detail/binbsu37/4304645
总结以上是内存溢出为你收集整理的VB调用Delphi编写的DLL - 2全部内容,希望文章能够帮你解决VB调用Delphi编写的DLL - 2所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)