asp封装成DLL 能像VB中一样操作INI文件吗?

yejian520 2009-07-28 05:59:23
在VB中很容易的实现了操作INI配置文件
我现在需要ASP去读取一个INI文件,我找了好久没有找到代码,如果我把这个封装到DLL中再用ASP调用
是不是就能达到用VB读取INI的效果呢?可同样的代码我放进去执行起来好像是没效果的,有谁知道答案

如果真不行,难道要用FSO去读取要的行,再做数据处理吗?那样好像效率有问题啊
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yejian520 2009-07-28
  • 打赏
  • 举报
回复
搞定

Public Function GetIni1(ByVal strPrimary As String, ByVal strSubKey As String, ByVal strIniFilePath As String) As String
Dim myFso As FileSystemObject
Dim MyFile As TextStream

Dim intCount As Integer, strState As String
Set myFso = New FileSystemObject
Set MyFile = myFso.OpenTextFile(strIniFilePath, 1, False, False)
With MyFile
Do Until .AtEndOfStream
If intCount = 0 Then
If .ReadLine = "[" & strPrimary & "]" Then
intCount = 1
End If
Else
strState = .ReadLine
If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then
GetIni1 = Right(strState, Len(strState) - Len(strSubKey & "="))
End If
End If
Loop
.Close
End With
Set MyFile = Nothing
Set myFso = Nothing
End Function


Public Sub OnStartPage(PassedscriptContext As ScriptingContext)
Set Context = PassedscriptContext
Set Application = Context.Application
Set Request = Context.Request
Set Response = Context.Response
Set Server = Context.Server
Set Session = Context.Session
End Sub

Public Sub showsuc()
Dim file
file = App.Path & "\config.ini"
Response.Write GetIni1("authorization", "code", file)
End Sub


引用ASP和FSO
这样执行起来就OK了
hookee 2009-07-28
  • 打赏
  • 举报
回复
有组件可以用的
免费的 http://www.abysslabs.com/products/com/inifile.phtml
hanaq82 2009-07-28
  • 打赏
  • 举报
回复
你在VB中是什么类实现的,你可以在asp中引用这个方法,也是可以实现的。

其实最好的方法,就是用VB写个操作ini文件的DLL控件,之后在asp中来调用,这种方法最快也也最直接。
当然服务器上要能注册这个这个DLL控件了。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧