VB 读取收藏夹里的URL地址_VB.net_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

VB 读取收藏夹里的URL地址

作者:黑客防线网安VB教程基地 来源:黑客防线网安VB教程基地 浏览次数:0

本篇关键词:地址收藏夹读取 
黑客防线网安网讯:Public Const MAX_PATH As Long = 260Public Const ERROR_SUCCESS As Long = 0Public Const S_OK As Long = 0Public Const S_FALSE As Long = 1Public Const SHGFP_TYPE_CURRENT As Long = ...

Public Const MAX_PATH As Long = 260
Public Const ERROR_SUCCESS As Long = 0
Public Const S_OK As Long = 0
Public Const S_FALSE As Long = 1
Public Const SHGFP_TYPE_CURRENT As Long = &H0
Public Const SHGFP_TYPE_DEFAULT As Long = &H1
Public Const CSIDL_FAVORITES As Long = &H6

Public Declare Function SHGetFolderPath Lib "shfolder" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwReserved As Long, ByVal lpszPath As String) As Long

Public Function GetFolderPath(CSIDL As Long) As String
Dim sPath As String
Dim sTmp As String
sPath = Space$(MAX_PATH)
'下面的0为窗口句柄如果为单窗口程序最好指定为mainform.hwnd
If SHGetFolderPath(0, CSIDL, 0&, SHGFP_TYPE_CURRENT, sPath) = S_OK Then
    GetFolderPath = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
End If
End Function
'获取收藏夹下url文件的URL地址
Public Function ProfileGetItem(lpSectionName As String, lpKeyName As String, defaultValue As String, inifile As String) As String

'Retrieves a value from an ini file corresponding
'to the section and key name passed.
       
   Dim success As Long
   Dim nSize As Long
   Dim ret As String
 
  'call the API with the parameters passed.
  'The return value is the length of the string
  'in ret, including the terminating null. If a
  'default value was passed, and the section or
  'key name are not in the file, that value is
  'returned. If no default value was passed (""),
  'then success will = 0 if not found.

  'Pad a string large enough to hold the data.
   ret = Space$(2048)
   nSize = Len(ret)
   success = GetPrivateProfileString(lpSectionName, lpKeyName, _
                                     defaultValue, ret, nSize, inifile)
  
   If success Then
      ProfileGetItem = Left$(ret, success)
   End If
  
End Function

使用方法

Dim lpszRootFolder As String
Dim sURL As String
lpszRootFolder = GetFolderPath(CSIDL_FAVORITES)
sURL = ProfileGetItem("InternetShortcut", "URL", "", lpszRootFolder & "" & "filename.url")

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14690-1.html
网站维护教程更新时间:2012-04-03 01:12:36  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer