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') 测试不在有问题
 
随机推荐
- [转帖]iometer - 性能压力测试工具
			
<存储工具系列文章>主要介绍存储相关的测试和调试工具,包括不限于dd.fio.vdbench.iozone.iometer.cosbench等性能负载工具,及strace等调试工具. 1 ...
 - [转帖] 常见的Socket网络异常场景分析
			
https://www.cnblogs.com/codelogs/p/16001770.html 原创:打码日记(微信公众号ID:codelogs),欢迎分享,转载请保留出处. 简介# 在目前微服务的 ...
 - Redisson/Jedis 线程数不足报错问题的思考
			
Redisson/Jedis 线程数不足报错问题的思考 背景 最近公司内总出现 Redis相关的错误 !-_-! 看我最近发的博客就可以看的出来. 这个错误提示其实是 两年前 清明节进行 压测时发现的 ...
 - [转帖]Mars II - Microarchitectures - Phytium
			
https://en.wikichip.org/wiki/phytium/microarchitectures/mars_ii Edit Values Mars II µarch General In ...
 - [转帖]总结:Servlet
			
一.背景 开发了很久的web服务,使用了很多web框架,都忘记web技术最原始的模样了,今天来回顾下. 二.Servlet是什么? Servlet是sun公司提供的一门用于开发动态web资源的技术.我 ...
 - [转帖]LTP使用和分析
			
一.安装及编译流程 1.下载LTP LTP 项目目前位于 GitHub,项目地址:https://github.com/linux-test-project/ltp . 获取最新版可以执行以下命令: ...
 - Redis启用认证
			
要在Redis中启用认证,您需要在Redis配置文件中设置requirepass指令.以下是步骤: 找到Redis配置文件.这通常是redis.conf,可能位于/etc/redis/或/etc/目录 ...
 - C语言输出键盘
			
使用printf()函数输出样式 #include <stdio.h> int main() { printf("┌───┬───┬───┬───┬───┬───┬───┬─── ...
 - arch linux 安装
			
好长时间都没有更新自己的博客了,我简单翻阅了一下自己的更新记录,上一次更新好像还是在5月份左右,距今也有快半年,这半年也是遇到了很多事情,有不好的,也有好的.这半年我对在日常生活工作中使用Linux系 ...
 - ElasticSearch安装、插件介绍及Kibana的安装与使用详解
			
ElasticSearch安装.插件介绍及Kibana的安装与使用详解 1.安装 ElasticSearch 1.1 安装 JDK 环境 因为 ElasticSearch 是用 Java 语言编写的, ...