怎样得到以下3个系统文件夹的路径?

stanely 2002-03-04 01:20:51
1.桌面.
2.系统system目录
3.windows目录.
...全文
44 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
辉歌 2002-03-04
  • 打赏
  • 举报
回复
uses shlobj
stanely 2002-03-04
  • 打赏
  • 举报
回复
delphi6里面不行呀:
uses
windows,shellapi,.....;

var
p:pchar
begin

shgetspecialfolderlocation(handle,CSIDL_DESKTOPDIRECTORY,p);

end;

//////////
[Error] Main.pas(193): Undeclared identifier: 'shgetspecialfolderlocation'

[Error] Main.pas(193): Undeclared identifier: 'CSIDL_DESKTOPDIRECTORY'
tg123 2002-03-04
  • 打赏
  • 举报
回复
vb程序供参考

Const CSIDL_DESKTOP = &H0
Private Const CSIDL_SYSTEM = &H25
Private Const CSIDL_WINDOWS = &H24

Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'Show an about window
ShellAbout Me.hWnd, App.Title, "Created by the KPD-Team 1999", ByVal 0&
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Print the folders to the form
Me.Print " 系统system目录" + GetSpecialfolder(CSIDL_SYSTEM)
Me.Print "windows目录.: " + GetSpecialfolder(CSIDL_WINDOWS)
Me.Print "桌面.: " + GetSpecialfolder(CSIDL_DESKTOP)
End Sub
Private Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long
Dim IDL As ITEMIDLIST
'Get the special folder
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = NOERROR Then
'Create a buffer
Path$ = Space$(512)
'Get the path from the IDList
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
'Remove the unnecessary chr$(0)'s
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
hexuexun 2002-03-04
  • 打赏
  • 举报
回复
BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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