vb6 中的 CommonAppData

发布于 2024-09-06 01:47:41 字数 464 浏览 4 评论 0原文

基本上与这个问题相同,但针对VB6

客户的应用程序“AppName”有 其配置文件存储在 通用应用程序数据。

  • 在 Windows XP 下,路径为 C:\Documents and Settings\All 用户\应用程序数据\应用程序名称
  • 在 Windows Vista 下为 C:\ProgramData\AppName

如何使用 VB6 获取正确的文件夹名称?

附加说明,我更喜欢使用 API 调用,而不是添加对 shell32.dll 的引用

Basically the same as this question, but for VB6.

A customer's application "AppName" has
its configuration files stored in
CommonAppData.

  • Under Windows XP that is C:\Documents and Settings\All
    Users\Application Data\AppName
  • Under Windows Vista that is C:\ProgramData\AppName

How do I get the correct foldername with VB6??

Additional notes, I prefer to use a API Call instead of adding a reference to the shell32.dll

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纵性 2024-09-13 01:47:41

使用后期绑定:

Const ssfCOMMONAPPDATA = &H23
Dim strCommonAppData As String

strCommonAppData = _
    CreateObject("Shell.Application").NameSpace(ssfCOMMONAPPDATA).Self.Path

Use late binding:

Const ssfCOMMONAPPDATA = &H23
Dim strCommonAppData As String

strCommonAppData = _
    CreateObject("Shell.Application").NameSpace(ssfCOMMONAPPDATA).Self.Path
无言温柔 2024-09-13 01:47:41

找到了;

Private Declare Function SHGetFolderPath _
                        Lib "shfolder.dll" Alias "SHGetFolderPathA" _
                        (ByVal hwndOwner As Long, _
                         ByVal nFolder As Long, _
                         ByVal hToken As Long, _
                         ByVal dwReserved As Long, _
                         ByVal lpszPath As String) As Long
Private Const CSIDL_COMMON_APPDATA = &H23
Private Const CSIDL_COMMON_DOCUMENTS = &H2E

Public Function strGetCommonAppDataPath() As String
    Dim strPath As String

    strPath = Space$(512)
    Call SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, 0, strPath)
    strPath = Left$(strPath, InStr(strPath, vbNullChar))

    strGetCommonAppDataPath = strPath
End Function

found it;

Private Declare Function SHGetFolderPath _
                        Lib "shfolder.dll" Alias "SHGetFolderPathA" _
                        (ByVal hwndOwner As Long, _
                         ByVal nFolder As Long, _
                         ByVal hToken As Long, _
                         ByVal dwReserved As Long, _
                         ByVal lpszPath As String) As Long
Private Const CSIDL_COMMON_APPDATA = &H23
Private Const CSIDL_COMMON_DOCUMENTS = &H2E

Public Function strGetCommonAppDataPath() As String
    Dim strPath As String

    strPath = Space$(512)
    Call SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, 0, strPath)
    strPath = Left$(strPath, InStr(strPath, vbNullChar))

    strGetCommonAppDataPath = strPath
End Function
吖咩 2024-09-13 01:47:41

卡尔·彼得森 (Karl Peterson) 已发布 名为 CSystemFolders 的嵌入式 VB6 类,它将查找 CSIDL_APPDATA、CSIDL_LOCAL_APPDATA 和 CSIDL_COMMON_APPDATA。

Karl 的代码始终可靠,不接受替代品:)

Karl Peterson has published a drop-in VB6 class called CSystemFolders that will find CSIDL_APPDATA, CSIDL_LOCAL_APPDATA and CSIDL_COMMON_APPDATA.

Karl's code is always reliable, accept no substitutes :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文