VB FTP上传和下载模块
Option Explicit
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const scuseragent = "vb wininet"
Private Const INTERNET_FLAG_PASSIVE = &H8000000
'调用设置环境
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
'连接服务器
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
'上传涵数
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Dim hOpen As Long
Dim hConnection As Long
'上传文件模块
Public Function UpLoadFile(IP As String, FileName As String, UserName As String, PassWord As String) As Boolean
Dim ShortName As String
Dim ret As Boolean
ShortName = GetShortName(FileName)
hOpen = TestServer
If hOpen <> 0 Then
hConnection = InterConnection(IP, UserName, PassWord)
If hConnection <> 0 Then
ret = FtpPutFile(hConnection, FileName, ShortName, 2, 0)
UpLoadFile = ret
Else
UpLoadFile = False
End If
Else
UpLoadFile = False
End If
InternetCloseHandle hConn
相关文档:
1、大道至简
米老师先呈现了一个函数的图像,然后问问大家想到了什么。
看到这张图,我先发现这是一个周期函数,再往深了就感觉自己应该不会了,寄希望于书信的几个同学,感觉应该是高数里的东西。但事实证明是初中的知识:
他是以下三个函数的复合函数:
y=sin(x)+sin(2x)+sin(3x)
& ......
本文引自。感谢原创!http://useway.blog.51cto.com/736087/176913
VB无所不能之三:VB截获Windows消息的钩子
——作者:钟声
博客地址:http://useway.blog.51cto.com
VB一直被认为是一个可以通过简单的方法,完成Windows界面应用程序的一个语言。对Windows系统方面的编程似乎首 ......
1、先把VB编译好的DLL文件放到系统的SYSTEM32文件夹下
2、用regsvr32注册这个DLL文件
3、Pb下调用
oleobject ole_1
ole_1=create oleobject
long ll_ret
ll_ret=ole_1.connecttonewobject( 'add.addstring ')//其中add为VB的工程名,addstring为VB的类模块名
string ls_message, ......
VC函数是:extern "C" int __declspec(dllexport)PassPortRead(char *InPutData,char OuPutData[255]);
VB声明是:Private Declare Function PassPortRead Lib "PPRead.dll" (ByVal InPutData As String, ByVal OutPutData As String) As Integer
生成的文件能正常运行,并且能生成相应数据,但是在调试时提示"DLL调用约定错 ......
※==================================================================
※本连载文章说明:
※1、连载首发于《软件报》(http://www.sweek.com)2006年21期(2006年5月22日);
※2、此次网上连载采用的是原稿件结构,内容与《软件报》发表略有不同;
※3、谢绝除《软件报》及其相关刊物之外的传统媒体部分或全部转载 ......