获取系统特殊文件夹的路径

System权限下进程遇到的问题以及如何降权启动进程 一. 背景最近项目上踩到一个坑,即偶现升级过程中通过计划任务调起新安装包,程序安装到了错误的地方,并且桌面快捷方式等入口均没有生成,总而言之就是一个“自杀”行为。二. 原因通过测试发现原因:在有些情况下,通过计划任务(通过服务也是如此)调起的进程是system权限的。而在system权限下进程可能会遇到很多问题: 通过注册表或expand 环境变量等方法得到的系统目录并不是我们想要的,例如 阅读详情
TCHAR strDir[_MAX_PATH];  

SHGetSpecialFolderPath(0,MyDir,CSIDL_APPDATA,0);

MessageBox(0,strDir,0,0);

 
其中第三个参数CSIDL_APPDATA可以为以下的值:


  CSIDL_BITBUCKET   回收站    
  CSIDL_CONTROLS   控制面板    
  CSIDL_DESKTOP   Windows   桌面Desktop    
  CSIDL_DESKTOPDIRECTORY   Desktop的目录    
  CSIDL_DRIVES   我的电脑    
  CSIDL_FONTS   字体目录    
  CSIDL_NETHOOD   网上邻居    
  CSIDL_NETWORK   网上邻居虚拟目录    
  CSIDL_PERSONAL   我的文档    
  CSIDL_PRINTERS   打印机    
  CSIDL_PROGRAMS   程序组    
  CSIDL_RECENT   最近打开的文档    
  CSIDL_SENDTO   “发送到”菜单项    
  CSIDL_STARTMENU   任务条启动菜单项    
  CSIDL_STARTUP   启动目录    
  CSIDL_TEMPLATES   文档模板      


//如果下面的值在VC开发环境中不存在话,可以在VC98/include/SHLOBJ.H中定义该变量
CSIDL_FLAG_CREATE(0x8000)  
Version 5.0. Combine this CSIDL with any of the following CSIDLs to force the creation of the associated folder.  


CSIDL_ADMINTOOLS(0x0030)
Version 5.0. The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user.


CSIDL_ALTSTARTUP(0x001d)
The file system directory that corresponds to the user's nonlocalized Startup program group.


CSIDL_APPDATA(0x001a)
Version 4.71. The file system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable Shfolder.dll for systems that do not have the Microsoft® Internet Explorer 4.0 integrated Shell installed.


CSIDL_BITBUCKET(0x000a)
The virtual folder containing the objects in the user's Recycle Bin.


CSIDL_CDBURN_AREA(0x003b)
Version 6.0. The file system directory acting as a staging area for files waiting to be written to CD. A typical path is C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\CD Burning.


CSIDL_COMMON_ADMINTOOLS(0x002f)
Version 5.0. The file system directory containing administrative tools for all users of the computer.


CSIDL_COMMON_ALTSTARTUP(0x001e)
The file system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Microsoft Windows NT® systems.


CSIDL_COMMON_APPDATA(0x0023)
Version 5.0. The file system directory containing application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data.


CSIDL_COMMON_DESKTOPDIRECTORY(0x0019) //获取桌面


CSIDL_COMMON_DOCUMENTS(0x002e)
The file system directory that contains documents that are common to all users. A typical paths is C:\Documents and Settings\All Users\Documents. Valid for Windows NT systems and Microsoft Windows® 95 and Windows 98 systems with Shfolder.dll installed.


CSIDL_COMMON_FAVORITES(0x001f) //获取收藏文件夹
The file system directory that serves as a common repository for favorite items common to all users. Valid only for Windows NT systems.


CSIDL_COMMON_MUSIC(0x0035)
Version 6.0. The file system directory that serves as a repository for music files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Music.


CSIDL_COMMON_PICTURES(0x0036)
Version 6.0. The file system directory that serves as a repository for image files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Pictures.


CSIDL_COMMON_PROGRAMS(0x0017) //获取程序菜单目录
The file system directory that contains the directories for the common program groups that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT systems.


CSIDL_COMMON_STARTMENU(0x0016) //开始菜单
The file system directory that contains the programs and folders that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems.


CSIDL_COMMON_STARTUP(0x0018) //获取启动菜单
The file system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems.


CSIDL_COMMON_TEMPLATES(0x002d) //临时文件夹
The file system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT systems.


CSIDL_COMMON_VIDEO(0x0037)
Version 6.0. The file system directory that serves as a repository for video files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Videos.


CSIDL_CONTROLS(0x0003)
The virtual folder containing icons for the Control Panel applications.


CSIDL_COOKIES(0x0021) //获取Cookies目录
The file system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies.


CSIDL_DESKTOP(0x0000) //获取桌面
The virtual folder representing the Windows desktop, the root of the namespace.


CSIDL_DESKTOPDIRECTORY(0x0010) //获取桌面
The file system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself). A typical path is C:\Documents and Settings\username\Desktop.


CSIDL_DRIVES(0x0011)
The virtual folder representing My Computer, containing everything on the local computer: storage devices, printers, and Control Panel. The folder may also contain mapped network drives.


CSIDL_FAVORITES(0x0006)
The file system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites.


CSIDL_FONTS(0x0014) //获取字体目录
A virtual folder containing fonts. A typical path is C:\Windows\Fonts.


CSIDL_HISTORY(0x0022) //获取历史目录
The file system directory that serves as a common repository for Internet history items.


CSIDL_INTERNET(0x0001)
A virtual folder representing the Internet.


CSIDL_INTERNET_CACHE(0x0020)
Version 4.72. The file system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Local Settings\Temporary Internet Files.


CSIDL_LOCAL_APPDATA(0x001c)
Version 5.0. The file system directory that serves as a data repository for local (nonroaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data.


CSIDL_MYDOCUMENTS(0x000c)
Version 6.0. The virtual folder representing the My Documents desktop item. This should not be confused with CSIDL_PERSONAL, which represents the file system folder that physically stores the documents.


CSIDL_MYMUSIC(0x000d)
The file system directory that serves as a common repository for music files. A typical path is C:\Documents and Settings\User\My Documents\My Music.


CSIDL_MYPICTURES(0x0027)
Version 5.0. The file system directory that serves as a common repository for image files. A typical path is C:\Documents and Settings\username\My Documents\My Pictures.


CSIDL_MYVIDEO(0x000e)
Version 6.0. The file system directory that serves as a common repository for video files. A typical path is C:\Documents and Settings\username\My Documents\My Videos.


CSIDL_NETHOOD(0x0013)
A file system directory containing the link objects that may exist in the My Network Places virtual folder. It is not the same as CSIDL_NETWORK, which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood.


CSIDL_NETWORK(0x0012)
A virtual folder representing Network Neighborhood, the root of the network namespace hierarchy.


CSIDL_PERSONAL(0x0005)
The file system directory used to physically store a user's common repository of documents. A typical path is C:\Documents and Settings\username\My Documents. This should be distinguished from the virtual My Documents folder in the namespace, identified by CSIDL_MYDOCUMENTS. To access that virtual folder, use SHGetFolderLocation, which returns the ITEMIDLIST for the virtual location, or refer to the technique described in Managing the File System.


CSIDL_PRINTERS(0x0004)
The virtual folder containing installed printers.


CSIDL_PRINTHOOD(0x001b)
The file system directory that contains the link objects that can exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood.


CSIDL_PROFILE(0x0028)
Version 5.0. The user's profile folder. A typical path is C:\Documents and Settings\username. Applications should not create files or folders at this level; they should put their data under the locations referred to by CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.


CSIDL_PROFILES(0x003e)
Version 6.0. The file system directory containing user profile folders. A typical path is C:\Documents and Settings.


CSIDL_PROGRAM_FILES(0x0026)
Version 5.0. The Program Files folder. A typical path is C:\Program Files.


CSIDL_PROGRAM_FILES_COMMON(0x002b)
Version 5.0. A folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT, Windows 2000, and Windows XP systems. Not valid for Windows Millennium Edition (Windows Me).


CSIDL_PROGRAMS(0x0002)
The file system directory that contains the user's program groups (which are themselves file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs.  


CSIDL_RECENT(0x0008)
The file system directory that contains shortcuts to the user's most recently used documents. A typical path is C:\Documents and Settings\username\My Recent Documents. To create a shortcut in this folder, use SHAddToRecentDocs. In addition to creating the shortcut, this function updates the Shell's list of recent documents and adds the shortcut to the My Recent Documents submenu of the Start menu.


CSIDL_SENDTO(0x0009)
The file system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo.


CSIDL_STARTMENU (0x000b) ///开始菜单
The file system directory containing Start menu items. A typical path is C:\Documents and Settings\username\Start Menu.


CSIDL_STARTUP(0x0007)
The file system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT or starts Windows 95. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup.


CSIDL_SYSTEM(0x0025) ///系统目录
Version 5.0. The Windows System folder. A typical path is C:\Windows\System32.


CSIDL_TEMPLATES(0x0015)
The file system directory that serves as a common repository for document templates. A typical path is C:\Documents and Settings\username\Templates.


CSIDL_WINDOWS(0x0024) ///Windows目录
Version 5.0. The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\Windows.
C#实现获取系统特殊文件夹路径(附完整源代码) 阅读详情

相关推荐

VC 获取系统特殊文件夹的路径如:系统目录,桌面等

VC 获取系统特殊文件夹的路径如:系统目录,桌面等

vc 判断当前用户是否在管理员组以及是否SYSTEM权限运行

BOOL IsUserInAdminGroup() //判断是否在管理员组 { BOOL fInAdminGroup = FALSE; HANDLE hToken = NULL; HANDLE hTokenToCheck = NULL; DWORD cbSize = 0; OSVERSIONINFO osver = {0}; ...

weixin_30781775的博客 442

VC++获取桌面文件及快捷方式列表

VC++源码,可以获取当前用户及所有用户桌面上的文件及快捷方式列表

VC++ 获取系统特殊文件夹的路径 桌面等

VC 获取系统特殊文件夹的路径如:系统目录,桌面等 qtom: TCHAR MyDir[_MAX_PATH];  SHGetSpecialFolderPath(this->GetSafeHwnd(),MyDir,CSIDL_APPDATA,0); AfxMessageBox(MyDir); 其中第三个参数CSIDL_APPDATA可以为以下的值: CSIDL_BITBUC

bingkehanfeng的专栏 2969

MySQL8.2.0下载安装

4、点击No thanks,just start my download,就是只是开始下载的意思,点击下载,等待下载完成。5、新建空白行,或直接双击紧挨的空白行,把复制的mysql的安装路径bin路径复制粘贴过来,确定,确定,确定。1、上面点击finish后,自动勾选了run mysql配置,自动会打开配置页面,点击Next。1、双击安装包,进入安装流程,勾选我同意 I accept,next。2、根据自己需要选择,我选的第二个,可以自己改安装路径。2、默认,点击Next,记住默认端口3306。

m0_59681797的博客 1万+

工业音频故障检测:从CNN到Transformer的技术演进

音频信号处理是工业设备预测性维护的核心技术之一,通过分析设备运行时产生的声波特征实现故障预警。传统方法依赖梅尔频率倒谱系数(MFCC)等手工特征,而深度学习技术尤其是Transformer架构,通过自注意力机制突破了CNN在跨频段特征提取上的局限。Audio Spectrogram Transformer(AST)等先进模型在工业场景中展现出91.2%的高召回率,显著优于传统方案。这种非接触式监测技术结合边缘计算优化,已成功应用于石油化工、电力能源等领域,实现提前72小时预测轴承故障,单项目可避免数百万元的

weixin_30467861的博客 328

C#获取Windows系统特殊文件夹的路径

转自 http://www.cnblogs.com/mane/archive/2011/08/13/2137215.html 系统特殊文件夹是包含公共信息的文件夹,如“Program Files”、“Programs”、“System”或“Startup”。特殊文件夹在默认情况下由系统设置,或者由用户在安装 Windows 的某个版本时显式进行设置。 Environme

月光轩辕的专栏 3444

Vivado实战:AXI转PCIe IP核配置全流程(含性能优化技巧)

本文详细介绍了在Vivado环境中配置AXI转PCIe IP核的全流程,包括工程准备、IP核参数设置、BAR空间配置、中断系统优化以及TLP传输效率提升等关键步骤。特别分享了经过验证的性能优化技巧,帮助开发者显著提升PCIe链路的吞吐量和稳定性,适用于视频采集、高速数据记录等应用场景。

weixin_30892037的博客 557

[C#]Windows系统特殊文件夹路径获取

由于软件开发的需要,近期对Windows特殊文件夹(如桌面,我的文档等)路径的查找方法进行了研究,结果如下。 获取特殊文件夹的方法不止一种,下面列出常用的几个方式。 一、使用 Environment.SpecialFolder 与 Enviroment.GetFolderPath() 简单直接的获取办法,能够获取系统自带

cym_hellfire的博客 2759

【异常】安装hermes-agent提示Git克隆仓库网络中断 fetch-pack: unexpected disconnect while reading sideband packet

本文分析了Git克隆仓库时出现网络中断错误的常见原因及解决方案。报错表现为连接被远程主机关闭、管道破裂或数据包意外终止,通常由网络不稳定、仓库过大或配置不当引起。提供了5种优先级排序的解决方法:1)使用浅克隆减少数据量;2)优化Git配置参数;3)切换网络或配置代理;4)检查SSH密钥设置;5)改用HTTPS方式克隆。特别推荐先尝试「浅克隆+HTTPS」组合方案快速验证,若问题持续再根据具体报错深入排查。文中包含详细的命令示例和配置说明,适合不同网络环境下的Git用户参考。

奶爸的编程之路,也就一周冷个三天 1427

手把手教你学BSP(11.3)--BSP实例:基于Raspberry Pi 4 Model B的Linux BSP开发实例

通过以上步骤,我们完成了一个基于Raspberry Pi 4 Model B的Linux BSP开发过程,包括硬件初始化、设备驱动编写、Bootloader配置、内核配置和编译,以及最终映像的生成。每个步骤都非常重要,确保每一步都正确无误才能使整个系统正常运行。

MHD0815的博客 1019

C#获取Windows系统特殊文件夹的路径[转]

系统特殊文件夹是包含公共信息的文件夹,如“Program Files”、“Programs”、“System”或“Startup”。特殊文件夹在默认情况下由系统设置,或者由用户在安装 Windows 的某个版本时显式进行设置。 Environment.GetFolderPath 方法 获取指向由指定枚举标识的系统特殊文件夹的路径。 命名空间:Systempublic ...

weixin_33929309的博客 245

Allegro层叠中的Etch Factor-铜皮的腐蚀因子如何计算

在用Allegro进行PCB设计的时候,Cross-section中需要填入对应的信息,一般填入每层的厚度即可,如下图。当PCB需要进行仿真分析的时候,Etch-Factor这个值是必须要填写的,如下图。实际铜皮进行蚀刻的时候,Etch-Factor的值并不是标准的90度,如下图。线路层实际形状是个梯形,Etch-Factor代表的就是梯形的角度,如下图。首先输入数值,比如1,再点击Inv,最后点击tan-1,可以得到角度的值。如果tanσ=2,σ=63.4,如下图计算结果。即tanσ=1,得到σ=45。

weixin_54787054的博客 887

C#:获取Windows系统特殊文件夹的路径

Environment.GetFolderPath 方法 获取指向由指定枚举标识的系统特殊文件夹的路径。 命名空间:System public static string GetFolderPath ( SpecialFolder folder ) 参数 folder 标识系统特殊文件夹的枚举常数。 返回值 如果指定系统的特殊文件夹实际存在于您的计算机上,则为...

weixin_30593443的博客 104

C++笔记之emplace_back(),push_back()性能比较i++ 、 ++i

操作是否需要临时对象/拷贝性能需要(构造临时对象)较慢不需要(直接构造)较快i++需要(保存旧值)对于内置类型无影响,但对于自定义类型(如迭代器、大对象)会有拷贝开销++i不需要相对更快(尤其是自定义类型)都存在"是否需要额外的临时对象/拷贝"这一性能差异点和++i都是更高效的版本(避免临时对象/拷贝)和i++都可能产生额外的临时对象(前者构造临时对象,后者保存旧值)对于内置类型(如int),i++和++i性能几乎没有差异(编译器会优化);但对于自定义类型(尤其是迭代器等重量级对象),

小勇博客 105

YOLOv11低光照检测性能优化:基于Retinexformer主干网络的深度改进实践

购买即可解锁300+YOLO优化文章,并且还有海量深度学习复现项目,价格仅需两杯奶茶的钱,别人有的本专栏也有!@[TOC]在自动驾驶、安防监控、遥感探测等关键领域,目标检测系统必须保证24小时全天候的可靠工作。然而,现有最先进的目标检测模型,包括YOLOv11,其训练数据大多源于光照良好的场景。当环境光照条件急剧下降时,图像会出现严重的噪声、低对比度、颜色失真和细节丢失,直接导致模型性能断崖式下跌。常规的解决方案如图像直方图均衡化或简单的伽马校正,往往收效甚微,甚至可能放大噪声,进一步干扰检测。

m0_71589036的博客 193

VC获取系统特殊文件夹的路径

VC获取系统特殊文件夹的路径 : 系统临时文件夹/桌面/APPdata.....

kyowu的专栏 892

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

获取系统特殊文件夹路径

代码文件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm)  Memo1: TMemo;  procedure FormCreate(Sender: TObje...

luxuewei5214的专栏 196

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

上一篇: 独家记忆
下一篇: 获取硬盘序列号
sysprogram
博客等级 码龄17年 299粉丝 442原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值