WHO CAN HELP ME ???(200分)

  • 主题发起人 主题发起人 wang_guojian
  • 开始时间 开始时间
W

wang_guojian

Unregistered / Unconfirmed
GUEST, unregistred user!
那位能帮我把以下的 VB程序调试成功您将获得200分。(改装成DELPHI也行)<br>谢谢!!!<br>“问题出在 Private Sub C_OK_Click() &nbsp;调用FINDFIRSTFILEA( &nbsp; )时”<br>Private Type FILETIME<br>DWLOWDATETIME As Long<br>DWHIGHDATETIME As Long<br>End Type<br><br>Private Type WIN32_FIND_DATA<br>DWFILEATTRIBUTES As Long<br>FTCREATIONTIME As FILETIME<br>FTLASTACCESSTIME As FILETIME<br>FTLASTWRITETIME As FILETIME<br>NFILESIZEHIGH As Long<br>NFILESIZELOW As Long<br>DWRESERVED0 As Long<br>DWRESERVED1 As Long<br>CFILENAME As String * 256<br>CALTERNATE As String * 14<br>End Type<br>Private Declare Function FINDFIRSTFILE Lib "KERNEL32" Alias "FINDFIRSTFILEA" (ByVal LPFILENAME As String, LPFINDFILEDATA As WIN32_FIND_DATA) As Long<br><br><br>Private Declare Function DELETEFILE Lib "KERNEL32" Alias "DELETEFILEA" (ByVal LPFILENAME As String) As Long<br><br><br><br><br><br>Private Sub C_EXIT_Click() ‘退出按钮<br>Unload Me<br>End Sub<br><br>Private Sub C_OK_Click() &nbsp; ’确定按钮<br>If T_SOURCEFILE.Text = " " Then<br>MsgBox "必须有源文件名!", vbQuestion, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>If T_TARGETFILE.Text = " " Then<br>MsgBox "必须有目标文件名!", vbQuestion, "注意:"<br>T_TARGETFILE.SetFocus<br><br>End If<br><br>If T_SOURCEFILE.Text = T_TARGETFILE.Text Then<br>MsgBox "源文件[路径和文件名]不能与目标文件[路径和文件名]相同!", vbOKOnly, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>If T_ENCODE.Text &lt;&gt; T_CONFIRMENCODE.Text Then<br>MsgBox "确认密码不对!", vbQuestion, "注意:"<br>T_ENCODE.SetFocus<br>Exit Sub<br><br>End If<br><br>Dim FILEDATA As WIN32_FIND_DATA<br>If FINDFIRSTFILEA(T_SOURCEFILE.Text, FILEDATA) = -1 Then<br>MsgBox "源文件不存在!", vbOKOnly, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>Dim LENGTH As Integer<br>Dim I As Long<br>Dim ENCODE As Long<br>LENGTH = Len(T_ENCODE)<br><br>If LENGTH = 0 Then<br>ENCODE = -30<br>Else<br><br>For I = 1 To LENGTH<br>ENCODE = ENCODE + Asc(Mid(T_ENCODE, I, 1)) * 256 * I<br>Next I<br>ENCODE = -ENCODE<br>End If<br><br>Dim FN1 As Long<br>Dim FN2 As Long<br>FN1 = FreeFile<br>Open T_SOURCEFILE.Text For Binary Access Read As #FN1<br>FN2 = FreeFile<br>Open T_TARGETFILE.Text For Binary Access Write As #FN2<br>Form1.MousePointer = 11<br>ProgressBar1.Visible = TYUE<br>Dim FLENGTH As Long<br>Dim SIZE As Long<br>Dim BYTEBLOCK() As Byte<br>Dim POSITION As Long<br>Dim J As Long<br><br>FLENGTH = LOF(FN1)<br>SIZE = 32768<br>POSITION = 0<br>Rnd (ENCODE)<br>Do While POSITION &lt; FLENGTH<br>If FLENGTH - POSITION &lt; SIZE Then SIZE = FLENGTH - POSITION<br>ReDim BYTEBLOCK(1 To SIZE)<br>Get #FN1, POSITION + 1, BYTEBLOCK<br>For J = 1 To SIZE<br>BYTEBLOCK(J) = BYTEBLOCK(J) Xor Int(Rnd * 256)<br>Next J<br>Put #FN2, POSITION + 1, BYTEBLOCK<br>POSITION = POSITION + SIZE<br>ProgressBar1.Value = Int(POSITION / FLENGTH * 100)<br>Loop<br>Close FN1, FN2<br>If CB_DEL Then DELETEFILE (T_SOURCEFILE)<br>ProgressBar1.Visible = False<br>Form1.MousePointer = 0<br>MsgBox "加密/解密完毕!", vbOKOnly, "注意:"<br>End Sub<br><br>Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)<br><br>End Sub<br><br><br>Private Sub T_SOURCEFILE_DblClick() &nbsp; ’文本框一<br>CommonDialog1.DialogTitle = "打开源文件名:"<br>CommonDialog1.Filter = "所有文件(*.*)|*.*|*.JM文件|*.JM"<br>CommonDialog1.ShowOpen<br>If CommonDialog1.FileName &lt;&gt; " " Then<br>Dim LENGTH As Integer<br>Dim EXNAME As String<br>LENGTH = Len(CommonDialog1.FileName)<br>EXNAME = Mid(CommonDialog1.FileName, LENGTH - 3 + 1)<br>T_SOURCEFILE.Text = CommonDialog1.FileName<br>If UCase(EXNAME) = "JM" Then<br>T_TARGETFILE.Text = Mid(CommonDialog1.FileName, 1, LENGTH - 3)<br>Else<br>T_TARGETFILE.Text = CommonDialog1.FileName + ".JM"<br>End If<br>End If<br><br>End Sub<br><br>Private Sub T_TARGETFILE_DblClick() &nbsp; &nbsp;‘文本框二<br>CommonDialog1.DialogTitle = "打开目标文件名:"<br>CommonDialog1.Filter = "所有文件(*.*)|*.*|*.JM文件|*.JM"<br>CommonDialog1.ShowOpen<br>If CommonDialog1.FileName &lt;&gt; " " Then<br>T_TARGETFILE.Text = CommonDialog1.FileName + ".JM"<br>End If<br><br>End Sub<br>
 
其实如果判断文件是否存在用DIR()函数即可;<br>IF Dir (FileName) &lt;&gt; "" THEN<br>&nbsp; &nbsp; ,文件存在<br>ELSE<br>&nbsp; &nbsp; '文件不存在<br>END IF<br>Dir后还可以接一参数,可以判断是文件还是文件夹.<br>
 
函数没有问题,以下是我的测试码:<br>Dim myFile As WIN32_FIND_DATA<br>If FindFirstFile("c:/command.com", myFile) = -1 Then<br>&nbsp; &nbsp; MsgBox "Can't find file"<br>Else<br>&nbsp; &nbsp; MsgBox "Find File"<br>End If<br><br>不过,最好先用FindClose<br>Dim myFile As WIN32_FIND_DATA<br>Dim lngFind As Long<br>FindClose lngFind<br>lngFind = FindFirstFile("c:/command.com", myFile)<br>If lngFind = -1 Then<br>&nbsp; &nbsp; MsgBox "Can't find file"<br>Else<br>&nbsp; &nbsp; MsgBox "Find File"<br>End If<br><br>
 
感谢 KILL NIGHT 的热心肠。可能是我太笨,按您的方法不能运行。<br>每次我调用时,程序老是报 ”子程序函数未定义“。按您的方法时<br>则报找不到DDL入口接点 FINDFIRSTFILE IN KERNEL32。您把程序完整的<br>调试一遍,并把完整程序告诉我,可以吗?(当然您能把所有改动告诉我也行)<br>同时欢迎更多的热心人来帮助我!!!!<br>对于分数我会毫不吝啬。<br><br>
 
(极为疑惑的)大富翁究竟是干吗的?<br>&nbsp;怎么什么都有?
 
在工程中加入一个Module,将FindFirstFile那些声明全部以Public形式放在<br>这个MODULE中就可以了。
 
感谢 KILL NIGHT &amp; partisan 的热心肠。希望能和二位交朋友,我的E-MAIL 为<br>WANGGUOJIAN@263.net,再见!
 

Similar threads

Z
回复
5
查看
208
zhenghui
Z
E
回复
7
查看
320
e意孤行
E
V
回复
7
查看
172
visual_cjiajia
V
后退
顶部