C++ 将filesystem::path转换为const BYTE*
std::string s = fs::temp_directory_path().append(filename).string(); LPCBYTE str = reinterpret_cast<LPCBYTE>(s.c_str()),
RegSetValueExA的实战示例:
// using std::string... HKEY newValue; // don't use RegOpenKey()! It is provided only for backwards compatibility with 16bit apps...
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &newValue) == 0)
{
// this may lose data for non-ASCII characters!
std::string s = fs::temp_directory_path().append(filename).string(); // this will convert the ANSI string to Unicode for you...
RegSetValueExA(newValue, "myprogram", 0, REG_SZ, reinterpret_cast<LPCBYTE>(s.c_str()), s.size()+1); RegCloseKey(newValue);
} return 0; // using std::wstring... HKEY newValue; // don't use RegOpenKey()! It is provided only for backwards compatibility with 16bit apps...
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &newValue) == 0)
{
// no data loss here!
std::wstring s = fs::temp_directory_path().append(filename).wstring(); // no ANSI->Unicode conversion is performed here...
RegSetValueExW(newValue, L"myprogram", 0, REG_SZ, reinterpret_cast<LPCBYTE>(s.c_str()), (s.size()+1) * sizeof(WCHAR)); RegCloseKey(newValue);
} return 0;
C++ 将filesystem::path转换为const BYTE*的更多相关文章
- BOOST 之filesystem, path
目录[-] 使用 boost::filesystem 的第一个程序 清单 1. 用于确定某个文件的类型是否为 Directory 的代码 了解 Boost path 对象 清单 2. 创建 Boost ...
- File already exists: filesystem '/path/file', transaction svn常见错误解决方法
前言 多人任务基本都会用到SVN,于是提交的时候如果不先更新在提交或者操作顺序不对,会经常出现错误,其中File already exists: filesystem这个就是个常见问题,上网找了半天没 ...
- CString转换为const char*
CString str=_T("这是我的测试程序.");// 先得到要转换为字符的长度const size_t strsize=(str.GetLength()+1)*2; // ...
- OpenGL与vs编程——error C2440: “glMaterialfv”: 无法从“GLfloat”转换为“const GLfloat *”
void setMaterial(const GLfloat mat_diffuse[4],GLfloat mat_shininess){static const GLfloat mat_specul ...
- 终于搞定在VS2010中将CString转换为const char*
最近碰到了CString 转 const char *的问题. 以前只要简单的一个强制转换就OK了,可现在是不行了,搜索了很多资料,终于搞定,主要是Unicode和ANSI的问题,只要做一个转换就可以 ...
- VS2010中将CString转换为const char*
最近碰到了CString 转 const char *的问题. 以前只要简单的一个强制转换就OK了,可现在是不行了,搜索了很多资料,终于搞定,主要是Unicode和ANSI的问题,只要做一个转换就可以 ...
- 【DEBUG】不能将参数 1 从“CString”转换为“const char *”
1. 在vc6.0下用CString str;num = atoi(str);就可以顺利取到num: 但是同样代码拿到vs2008就报错,error C2664: "atoi": ...
- 【QT】QString类型转换为const char*(toLatin1)
Qstring str = "helloworld"; char *s; QByteArray ba = str.toLatin1(); s = ba.data(); toLati ...
- c#中char、string转换为十六进制byte的浅析
问题引出: string转换为byte(十六进制) static void Main(string[] args) { "; byte[] b = Encoding.Default.GetB ...
- Error fetching command 'collectstatic': You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. Command 'collectstatic' skipped
报错现象 报错解决 在 settings.py 中添加这一句话则可以解决 STATIC_ROOT = os.path.join(BASE_DIR, 'static') 测试不在有问题
随机推荐
- 【转帖】What are segfault rip/rsp numbers and how to use them
https://stackoverflow.com/questions/1456899/what-are-segfault-rip-rsp-numbers-and-how-to-use-them ...
- 【转帖】基于官方rpm包方式安装Oracle19c
https://blog.whsir.com/post-5489.html 本文基于Centos7.x环境,通过官方提供的rpm包来安装19c 1.下载Oracle19c安装包 https://w ...
- awk中的NR,FNR ,NF,$NF,RS,ORS,FS,OFS
awk中的NR,FNR ,NF,$NF,RS,ORS,FS,OFS https://www.cnblogs.com/zhangqingsh/archive/2013/04/24/3040801.htm ...
- Oracle PDB的相关使用说明
Oracle PDB的相关使用说明 摘要 PDB pluggable database 是Oracle12c以上的版本(Oracle18c.oracle19c) 新增加的一个特性. 他可以实现灵活插拔 ...
- redis 6源码解析之 sds
redis使用sds(simple dynamic string)实现了字符串的存储.sds实际上就是TLV格式的数据结构.其数据结构主要分为如下5种,主要分为首部和数据部分,首部给出了type和le ...
- VOP 消息仓库演进之路|如何设计一个亿级企业消息平台
作者:京东零售 李孟冬 VOP作为京东企业业务对外的API对接采购供应链解决方案平台,一直致力于从企业采购数字化领域出发,发挥京东数智化供应链能力,通过产业链上下游耦合与链接,有效助力企业客户的成本优 ...
- 最新 Hugging Face 强化学习课程(中文版)来啦!
人工智能中最引人入胜的话题莫过于深度强化学习 (Deep Reinforcement Learning) 了,我们在 2022 年 12 月 5 日开启了<深度强化学习课程 v2.0>的课 ...
- Linux 文件目录压缩与解压命令
Linux 文件目录压缩与解压命令,融合多部Linux经典著作,去除多余部分,保留实用部分. compress压缩: compress是个历史悠久的压缩程序,文件经它压缩后,其名称后面会多出 &quo ...
- 【Trento】遥感图像数据集提供下载
遥感图像处理学习(11)之Trento数据集 前言 遥感系列第11篇.遥感图像处理方向的学习者可以参考或者复刻 本文初编辑于2024年1月18日 2024年1月25日搬运至本人博客园平台 最近在复现论 ...
- vue下载本地文件 下载二进制流文件 兼容ie
vue-cli2要下载的静态文件放在static目录下,vue-cli3则放在public目录下 ie不支持 h5 的download写法,故用以下写法 <el-button type=&quo ...