VC++ API 如何获取文件夹路径

VC++获取Windows系统路径:从API演进到实战源码解析 在Windows系统编程中,文件路径管理是构建健壮应用程序的基础。其核心原理在于通过操作系统提供的标准接口动态获取系统预定义的特殊文件夹位置,而非硬编码路径,这确保了程序在不同系统配置和版本间的可移植性。这项技术的核心价值在于遵循Windows生态规范,实现用户数据与程序数据的正确分离,提升应用的安全性和用户体验。典型应用场景包括保存用户配置到AppData、访问文档或桌面目录、管理临时文件以及处理程序安装路径等。本文深入解析了从传统的GetWindowsDirectory到现代的SHGetKnownFol 阅读详情

这里介绍一个API来获取文件夹得路径:

char szSelected[MAX_PATH];//用来存放文件夹路径   

 BROWSEINFO    bi;   

 LPITEMIDLIST pidl;    

bi.hwndOwner = this->m_hWnd;    

bi.pidlRoot = NULL;    

bi.pszDisplayName = szSelected;   

 bi.lpszTitle = "选择输出文件路径";    

bi.ulFlags = BIF_RETURNONLYFSDIRS;

bi.lpfn = NULL;    

bi.lParam = NULL;    

bi.iImage = NULL;             

if((pidl = SHBrowseForFolder(&bi)) != NULL)

{       

 if(SUCCEEDED(SHGetPathFromIDList(pidl,   szSelected)))//得到文件夹的全路径,不要的话,只得本文件夹名       

 {            m_strFileOut =   szSelected;      

  }    

}

VC++系统各种路径信息的获取 ①、Windows、System32、temp 等目录的获取: TCHAR szPath[MAX_PATH] = {0}; GetSystemDirectory(szPath, MAX_PATH); //C:\WINDOWS\system32 GetWindowsDirectory(szPath, MAX_PATH); //C:\WINDOWS GetTempPath(MAX_PATH, 阅读详情

相关推荐

VC++ 文件路径选择与文件夹打开两种实现方法及示例

本文还有配套的精品资源,点击获取 简介:在VC++编程中,文件路径的选择和特定文件夹的打开是常见的用户交互需求。本教程详细介绍了两种不同的方式实现文件路径选择对话框,包括使用 CFileDialog 类和 OPENFILENAME 结构结合 GetOpenFileName 函数。此外,还讲解了如何使用 IShellItem ...

weixin_42584586的博客 2276

VC++ 获取文件夹路径

CFileDialog只能选择文件不能选择文件夹,MFC有选择文件夹的控件 BROWSEINFO   我们经常需要用到“选择文件夹”对话框,相应的API已经很好用,但稍嫌麻烦,所以我专门将其封装了一下,力求一步到位。 函数封装如下: /***************************************************************** ** 函数名:GetP

orange_xxx的专栏 1098

掌握VC++:获取系统路径的源码实现

Windows系统目录是操作系统的重要组成部分,它包含了系统运行所必需的核心文件和设置。这些目录通常存储在系统盘(通常是C盘)的根目录下,如Windows、System32和Program Files等。系统目录中的文件对于系统的启动、运行和稳定性至关重要,例如,Windows目录存储了系统核心文件和用户界面资源,而System32目录则包含了大部分的系统驱动和动态链接库(DLL)文件。系统目录的作用不仅限于存放系统文件,它们还通过预设的权限和访问控制列表(ACL)来确保系统安全。

weixin_42576467的博客 974

VC获取指定文件夹路径

VC获取指定文件夹路径 flyfish  2010-3-5 一 使用Shell函数1 获取应用程序的安装路径 TCHAR buf[_MAX_PATH];SHGetSpecialFolderPath(NULL,buf,CSIDL_PROGRAM_FILES,NULL);AfxMessageBox(buf);2 获取应用程序数据路径的文件夹 TCHAR bufA

二分掌柜的 4316

CFolderDialog VC++ mfc 获取“文件夹”的类

1、在解决方案中右键,添加——》现有项,把FolderDialog.h和FolderDialog.cpp添加到解决方案中 2、在主程序中添加 #include "FolderDialog.h" 3、把“浏览文件夹按钮中的代码.txt”中的内容添加到,浏览按钮的事件代码中 4、在“项目”-》属性-》配置属性-》C/C++——》预编译头——》创建/使用预编译头 中选择"不使用使用预编译头",否则编译会出错

VC获取Windows各种目录路径

VC获取Windows各种目录路径

Windows API函数获取指定文件目录下文件路径(vc6.0通过)

// FileOpt.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include using namespace std; #define MAX_NUM 262 // 删除指定目录

Kernel Main的专栏 4514

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

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

VC++根据文件全路径创建文件,没有的文件夹直接新建

在 VC++ 中,如果你想根据文件的全路径创建文件,并且在路径中包含的文件夹如果不存在时自动创建这些文件夹,可以使用 Windows API 来实现。- 如果路径中有多个层级的文件夹需要创建,你可能需要使用递归或循环来逐级创建文件夹,或者使用 `SHCreateDirectoryEx` 函数来一次性创建多层目录。1. **获取文件夹路径**:通过查找最后一个斜杠(`\\` 或 `/`)来分离文件名和文件夹路径。4. **关闭文件句柄**:使用 `CloseHandle` 关闭文件句柄。

estar3339的博客 617

API提取自身文件名,目录 .cpp

适合计算机专业大一新生

.NET MAUI 第13讲 深入探索 .NET MAUI Essentials:让应用感知设备与环境,打造智能体验

摘要:本文介绍了.NET MAUI Essentials库如何赋能移动应用感知设备环境的能力。文章详细讲解了设备信息获取(DeviceInfo)、网络状态监测(Connectivity)、地理位置服务(Geolocation)、地图集成(Map)以及传感器(Accelerometer等)等核心功能的使用方法,并提供了完整的代码示例。通过一个综合练习,展示了如何构建设备信息仪表板,实时显示设备参数和网络状态,并实现位置获取与地图导航功能。这些跨平台API能显著提升应用智能化和用户体验,同时保持代码简洁高效。

AlphaNil的博客 1097

vc++实现获取桌面应用程序图标位置(附带源码)

在 VC++ 中获取桌面应用程序图标的位置,一般涉及到访问 Windows 的文件系统并获取桌面快捷方式的位置。桌面上的快捷方式通常存储在用户的 "桌面" 文件夹中,并且这些快捷方式是 .lnk 文件格式。我们可以使用 Windows API 来列举文件夹中的文件,并确定它们是否是应用程序快捷方式(.lnk 文件)。

欢迎来到我的博客!这里是一个专注于计算机技术的分享平台,涵盖编程开发、算法研究、系统架构、软件工程等多个领域。无论你是初学者还是资深开发者,都能在这里找到有价值的内容。 1234

工程经验分享:PCIE(1)

本文介绍AXI Bridge For Pcie Express Gen3 Subsystem 的使用方法。这个IP兼具简单与实用性,将PCIE协议层实现于内部,仅留出AXI接口供开发者使用。开发者不需要处理复杂的PCIE协议数据,只需要对AXI总线有所了解即可,十分符合Xilinx一贯的开发风格。本文无关PCIE协议本身,仅分享实用性的工程经验,以PCIE IP为核心,一步一步搭建一个简单的子系统,以此说明用法。文中所有内容均已通过项目检验。

weixin_42415266的博客 3850

获取"我的文档“路径

From: http://blog.csdn.net/chinabinlang/article/details/8637362 方法一:来自网络; CStirng getMyDoc() { TCHAR m_lpszDefaultDir[MAX_PATH]={0}; TCHAR szDocument[MAX_PATH]={0}; memset(m_lpszDefaul

JoeBlackZQQ的专栏 4675

内网CentOS离线部署LibreOffice:从依赖缺失到服务启动的完整避坑指南

本文详细介绍了在CentOS内网环境中离线部署LibreOffice的完整流程,包括依赖包准备、安装顺序优化及常见报错解决方案。针对金融等封闭网络场景,提供从rpm包选择到服务启动的全套避坑指南,特别解决libXinerama等图形库缺失问题,确保文档转换服务稳定运行。

weixin_33416697的博客 251

Arcgis空间分布方向性分析

Arcgis空间分布方向性分析 一、标准差椭圆方法概述 空间分布方向性分析是指区域经济属性在空间分布上的轮廓和主导方向。 标准差椭圆法是分析空间分布方向性特征的经典方法之一,使用标准差椭圆可 从全局的、空间的角度定量解释经济要素空间分布的中心性、展布性、方向性和 空间形态等整体性特征,因其直观性与有效性已得到广泛应用,已成为 Arc GIS 空间统计模块的常规统计工具。SDE 方法生成的结果为一个椭圆,从其生 成算法来看,首先用平均中心来确定椭圆的圆心,然后由平均中心作为起点 对 X 坐标

端木宛白的博客家园 4万+

获取我的文档路径

方法一:来自网络; CStirng getMyDoc() { TCHAR m_lpszDefaultDir[MAX_PATH]={0}; TCHAR szDocument[MAX_PATH]={0}; memset(m_lpszDefaultDir,0,_MAX_PATH); LPITEMIDLIST pidl=NULL; SHGetSpecialFolderLocation(NUL

chinabinlang的专栏 4134

ESP32网络开发实例-开发环境搭建

NodeMCU-ESP-32S开发环境搭建 NodeMCU-32S 最强的ESP32 开发板非盗版或副厂的CH340。WiFi 蓝牙ESP-32 可用Arduino IDE ESP32-S 是一款通用型WiFi-BT-BLE MCU模组,功能强大,用途广泛,可以用于低功耗传感器网络和要求极高的任务,例如语音编码、音频流和MP3解码等。 此款模组的核心是ESP32芯片,具有可扩展、自适应的特点。两个CPU核可以被单独控制或上电。时钟频率的调节范围为80 MHz到240 MHz。用户可以切断CPU的电源,利用低

视觉与物联智能 3790

SHGetSpecialFolderLocation 函数 中文介绍

WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderLocation (HWND hwndOwner, int nFolder,LPITEMIDLIST * ppidl); //函数声明 hwndOwner: 指定了"所有者窗口",在调用这个函数是可能出現的对话框或信息框. nFolder: 是一个整数id,決定哪个目录是待查找目录,它的取值可能是 CSID...

huozheleisi 133

CodeX 登录报错 os error 10013?一键修复 CodeX 无法登录问题(亲测有效)

CodeX 登录时报 os error 10013?本文提供快速修复方案,实测有效,彻底解决登录报错:登录失败:failed to start login server: 以一种访问权限不允许的方式做了一个访问套接字的尝试。 (os error 10013)的问题💡

XiaoqiangClub的博客 2966

C#函数返回多个值实现实例

本文实例讲解C#函数返回多个值多种实现方法。

qq_30725967的博客 1172

vc选取及保存文件对话框\浏览文件夹对话框

vc选取及保存文件对话框\浏览文件夹对话框 首先在Dialog上添加控件如下图: 在OnSelectFile()中添加如下代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15     CFileDialog  m_ReadDlg(TRUE);     m_ReadDlg.m_

zhangweijiqn的专栏 1804

使用MATLAB中的Simulink工具来构建一个微电网系统的仿真平台

微电网是指由分布式电源(如太阳能、风能等)、储能装置、负载以及控制和保护装置组成的局部电力系统。它可以独立于主电网运行,也可以与主电网并联运行。本示例将以一个简单的微电网为例,展示如何利用Simulink进行微电网接入与孤岛运行策略的设计与仿真。分布式电源:模拟太阳能光伏板或风力发电机等分布式电源。储能装置:用于存储多余能量或补充不足能量。负载:模拟实际用电需求。双向变流器:实现直流与交流之间的转换,并支持并网和孤岛模式切换。控制器:负责管理微电网的运行模式,包括并网控制和孤岛控制。

xiaoheshang_123的博客 349

VC++得到系统特殊文件夹路径

地址:http://blog.csdn.net/morewindows/article/details/8745532转载请标明出处,谢谢。欢迎关注微博:http://weibo.com/MoreWindows               VC++ 得到系统特殊文件夹路径       对Windows程序来说,得到系统特殊文件夹路径是个非常实用的功能。比如要执行一些系统程序像cmd.exe、msp

MoreWindows Blog 1万+

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

在MFC中如何获取文件和文件夹的路径

在VC++编程中,有时我们需要获得文件的luj

IT修道者的专栏 5656

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

VC++ MFC 获取文件路径 获取文件夹路径

//=文件的路径=== CString strPath = _T(""); CFileDialog Open(TRUE,_T("*.bmp"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("Bitmap Files (*.bmp)|*.bmp|JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*||"),NU

lyd_253261362的专栏 1万+

STM32F407中文手册

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

上一篇: VC++操作Excel在VS2008编码实例
下一篇: WM_NCHITTEST 消息使用解说
CreatedSign
博客等级 码龄14年 10粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址